FrostyX / tracer

Tracer finds outdated running applications in your system
GNU General Public License v2.0
81 stars 24 forks source link

AttributeError: module 'platform' has no attribute 'linux_distribution' on Python 3.9 #175

Closed jelly closed 2 years ago

jelly commented 2 years ago

When no /etc/os-release file is available the code falls back to calling platform.linux_distribution which has been deprecated and removed in [Python 3.8] (https://docs.python.org/2.7/library/platform.html?highlight=platform#platform.linux_distribution)

The Python docs recommend depending on the distro package, the code would become:

import distro
distro.linux_distribution(full_distribution_name=False)[0]
FrostyX commented 2 years ago

Hello @jelly, thank you for the report.

I created PR #176, what do you think?

jelly commented 2 years ago

Hello @jelly, thank you for the report.

I created PR #176, what do you think?

The PR looks fine to me, I have build an Arch Linux package with the patch running the tests and it succeeds. However running sudo tracer throws an traceback but I think it's unrelated to the PR:

[jelle@natrium][~/projects/tracer]%PYTHONPATH=. sudo python3 bin/tracer.py
posix.uname_result(sysname='Linux', nodename='natrium', release='5.13.10-arch1-1', version='#1 SMP PREEMPT Thu, 12 Aug 2021 21:59:14 +0000', machine='x86_64')
Traceback (most recent call last):
  File "/home/jelle/projects/tracer/bin/tracer.py", line 34, in <module>
    tracer.main.run()
  File "/home/jelle/projects/tracer/tracer/main.py", line 51, in run
    return router.dispatch()
  File "/home/jelle/projects/tracer/tracer/resources/router.py", line 52, in dispatch
    controller = DefaultController(self.args, self.packages)
  File "/home/jelle/projects/tracer/tracer/controllers/default.py", line 62, in __init__
    self.applications = self.tracer.trace_affected(self._user(args.user))
  File "/home/jelle/projects/tracer/tracer/resources/tracer.py", line 126, in trace_affected
    if not self._applications.find('kernel').ignore and self._has_updated_kernel():
  File "/home/jelle/projects/tracer/tracer/resources/tracer.py", line 134, in _has_updated_kernel
    running = System.running_kernel_package()
  File "/home/jelle/projects/tracer/tracer/resources/system.py", line 128, in running_kernel_package
    return System.package_manager().find_package(System.kernel_package_name(), os.uname()[2])
  File "/home/jelle/projects/tracer/tracer/resources/PackageManager.py", line 67, in find_package
    return self.package_managers[0].find_package(pkg_name, search)
  File "/home/jelle/projects/tracer/tracer/packageManagers/ipackageManager.py", line 47, in find_package
    raise NotImplementedError
NotImplementedError
jelly commented 2 years ago

Ah, this is due to find_package not being implemented for pyalpm, I quickly hacked it in but that requires a the correct kernel package to be provided.

It however stops tracer from showing a traceback, so I'll make a PR for that.

FrostyX commented 2 years ago

The PR looks fine to me, I have build an Arch Linux package with the patch running the tests and it succeeds. However running sudo tracer throws an traceback but I think it's unrelated to the PR:

Since we merged all related PRs, how does it work for you now? Can we merge the PR #176?

jelly commented 2 years ago

The PR looks fine to me, I have build an Arch Linux package with the patch running the tests and it succeeds. However running sudo tracer throws an traceback but I think it's unrelated to the PR:

Since we merged all related PRs, how does it work for you now? Can we merge the PR #176?

Sounds good to me. The tests run fine on Arch with #176