Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Compatibility with older versions of python3-apt. #287

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion agent/os_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ def upgrade_packages(pkg_names):
cache.update(apt.progress.text.AcquireProgress())
cache.open()
for pkg_name in unique_names:
pkg = cache.get(pkg_name)
# Older versions of python3-apt don't provide full dict interface, namely .get().
# The result of this expression will either be False or a apt.package.Package instance.
pkg = pkg_name in cache and cache[pkg_name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using readable if clause, you used a very tricky unreadable construction and had to add a special comment explaining it

if pkg and pkg.is_installed and pkg.is_upgradable:
packages.append(pkg_name)
pkg.mark_upgrade()
Expand Down