Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Jun 28, 2024
1 parent b38e0ea commit 2b285b9
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 61 deletions.
12 changes: 10 additions & 2 deletions dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# packages to install :

apt install python3-tabulate
apt install python3-colorama
# deb :
python3-tabulate
python3-colorama
python3-dateutil


# rpm :
python3-tabulate
python3-colorama
python3-dateutil
18 changes: 5 additions & 13 deletions src/controllers/Module/Reposerver/Status.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def sendGeneralStatus(self):
#
#-------------------------------------------------------------------------------------------------------------------
def sendPackagesStatus(self):
rc = 0

# Update Reposerver's request status, set it to 'running'
self.updateRequestStatus('packages-status-update', 'running')

Expand Down Expand Up @@ -204,16 +202,10 @@ def sendInstalledPackagesStatus(self):
name = package['name']
version = package['version']

# Ignore package if name is empty
if name == '':
# Ignore package if name or version is empty
if name == '' or version == '':
continue

# Redhat only
if self.systemController.getOsFamily() == 'Redhat':
# Remove epoch if it is equal to 0
if version.startswith('0:'):
version = version[2:]

# Add package name, its available version to the installed_packages string
installed_packages += name + '|' + version + ','

Expand Down Expand Up @@ -261,21 +253,21 @@ def sendFullHistory(self, entries_limit: int = 999999):

try:
# Retrieve history Ids or files
history_files = self.packageController.get_history(history_order)
history_entries = self.packageController.get_history(history_order)
except Exception as e:
self.updateRequestStatus('full-history-update', 'error')
raise Exception('error while retrieving history: ' + str(e))

# If there is no item (would be strange), exit
if len(history_files) == 0:
if len(history_entries) == 0:
print(' no history found')
self.updateRequestStatus('full-history-update', 'done')
return

# Parse history files / Ids
try:
events = {}
events['events'] = self.packageController.parse_history(history_files, entries_limit)
events['events'] = self.packageController.parse_history(history_entries, entries_limit)

# debug only: print pretty json
# import json
Expand Down
15 changes: 3 additions & 12 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ def getInstalledPackages(self):
for pkg in self.aptcache:
# If the package is installed, add it to the list of installed packages
if pkg.is_installed:
myPackage = {
list.append({
'name': pkg.name,
'version': pkg.installed.version,
}

list.append(myPackage)
})

# Sort the list by package name
list.sort(key=lambda x: x['name'])
Expand Down Expand Up @@ -362,14 +360,6 @@ def parse_history(self, history_files: list, entries_limit: int):
downgraded_packages = re.search(r'Downgrade: (.+)', event).group(1).strip()
if re.search(r'Reinstall: (.+)', event):
reinstalled_packages = re.search(r'Reinstall: (.+)', event).group(1).strip()

# TODO debug
# print('\n\n' + event + '\n')
# print(date_start)
# print(time_start)
# print(date_end)
# print(time_end)
# print(command)

# TODO : peut être pas utile finalement
# if count_event > 1:
Expand Down Expand Up @@ -402,6 +392,7 @@ def parse_history(self, history_files: list, entries_limit: int):
if reinstalled_packages != '':
reinstalled_packages_json = self.parse_packages_line_to_json(reinstalled_packages, 'reinstall')

# Create the event JSON object
event = {
'date_start': date_start,
'time_start': time_start,
Expand Down
Loading

0 comments on commit 2b285b9

Please sign in to comment.