Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Sep 5, 2024
1 parent c73e09a commit 58ecb89
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/controllers/Package/Apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ def __init__(self):
self.aptcache = apt.Cache()

# self.aptcache.update()
self.aptcache.open(None)
# self.aptcache.open(None)

# TODO debug
# Print content of apt cache
self.aptcache.upgrade()
to_update = self.aptcache.get_changes()

# for pkg in self.aptcache:
# print(pkg.name)
print('total 1: ' + str(len(to_update)))

# Total count of success and failed package updates
self.summary = {
Expand Down Expand Up @@ -70,13 +79,23 @@ def get_installed_packages(self):
#-----------------------------------------------------------------------------------------------
def get_available_packages(self, dist_upgrade: bool = False):
try:
aptcache = apt.Cache()
aptcache.open(None)
aptcache.clear()
aptcache.update()

list = []

# Simulate an upgrade
self.aptcache.upgrade(dist_upgrade)
# self.aptcache.upgrade(dist_upgrade)
aptcache.upgrade(dist_upgrade)

# TODO debug
print('total 2: ' + str(len(aptcache.get_changes())))

# Loop through all packages marked for upgrade
for pkg in self.aptcache.get_changes():
# for pkg in self.aptcache.get_changes():
for pkg in aptcache.get_changes():
# If the package is upgradable, add it to the list of available packages
if pkg.is_upgradable:
myPackage = {
Expand Down

0 comments on commit 58ecb89

Please sign in to comment.