From dd5d5bf23b4e9777571aee8bd7495f25dbd36c83 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 21 Nov 2016 08:13:08 +0100 Subject: Exempt display managers from the list of restartet services --- whatmaps/debiandistro.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 4fcce54..a85d9cd 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -63,8 +63,9 @@ class DebianDistro(Distro): service_blacklist = set(['kvm', 'qemu-kvm', 'qemu-system-x86']) # Per distro regex filter - service_blacklist_re = set([ - '^user@[0-9]+.service$', # Restarting systemd user service aborts the session + service_blacklist_re = set([ # Restarting these aborts the users session + '^user@[0-9]+.service$', + "^(g|k|light|no|sd|w|x)dm(.service)?$", ]) @classmethod -- cgit v1.2.3 From c77093fa9785ca894769d8145b1f2e370fcb90d2 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 25 Nov 2016 12:36:55 +0100 Subject: Exempt systemd-logind from list of restarted services since it aborts user sessions --- whatmaps/debiandistro.py | 1 + 1 file changed, 1 insertion(+) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index a85d9cd..ccc2139 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -65,6 +65,7 @@ class DebianDistro(Distro): # Per distro regex filter service_blacklist_re = set([ # Restarting these aborts the users session '^user@[0-9]+.service$', + "^systemd-logind.service$", "^(g|k|light|no|sd|w|x)dm(.service)?$", ]) -- cgit v1.2.3 From 51ed8c07a35a947d0ab2bc67aacef0af2441dcdf Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 25 Nov 2016 12:36:55 +0100 Subject: Exempt dbus from list of restarted services since it aborts gdm sessions --- whatmaps/debiandistro.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index ccc2139..57846ef 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -64,7 +64,8 @@ class DebianDistro(Distro): # Per distro regex filter service_blacklist_re = set([ # Restarting these aborts the users session - '^user@[0-9]+.service$', + "^dbus(.service)?$", + "^user@[0-9]+.service$", "^systemd-logind.service$", "^(g|k|light|no|sd|w|x)dm(.service)?$", ]) -- cgit v1.2.3 From db8576472e3c76dc495ba45792c8dc7f1bb4be46 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 15 Dec 2016 12:12:25 +0100 Subject: flake8 cleanups --- whatmaps/command.py | 1 + whatmaps/distro.py | 1 + 2 files changed, 2 insertions(+) diff --git a/whatmaps/command.py b/whatmaps/command.py index e28a8b9..74d85da 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -259,6 +259,7 @@ def main(argv): def run(): return(main(sys.argv)) + if __name__ == '__main__': sys.exit(main(sys.argv)) diff --git a/whatmaps/distro.py b/whatmaps/distro.py index 29d2dc2..87e264e 100644 --- a/whatmaps/distro.py +++ b/whatmaps/distro.py @@ -112,6 +112,7 @@ class Distro(object): def detect(): return detect() + import whatmaps.debiandistro # noqa: E402 import whatmaps.redhatdistro # noqa: E402 -- cgit v1.2.3 From 12d5965f82e706b4670710c16461e953882c65c4 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 15 Dec 2016 12:13:10 +0100 Subject: travis: Run nosetests as well --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 838cd99..ce0f500 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,6 @@ python: - "3.4" - "3.5" install: "pip install -r requirements.txt" -script: flake8 +script: + - flake8 + - nosetests -- cgit v1.2.3 From 56f6cb8933a0d7b618632ee63328813cd4d7f145 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 26 Dec 2016 10:08:12 +0100 Subject: manpage: fix path to README --- man/whatmaps.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/whatmaps.pod b/man/whatmaps.pod index 408e75d..c1d8d6b 100644 --- a/man/whatmaps.pod +++ b/man/whatmaps.pod @@ -26,7 +26,7 @@ prompting and with the I<--prind-cmds> option the restart commands are written t a file for later execution. On Debian systems B can also be run automatically by apt-get. See -L for details. +L for details. =head1 SEE ALSO -- cgit v1.2.3 From 69912f86329adf4df6c50741ca3f3635dd0cac0d Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 26 Dec 2016 10:05:25 +0100 Subject: Add simple helper to run from working copy since running whatmaps/command.py doesn't work with python3 --- run.py | 7 +++++++ whatmaps/command.py | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100755 run.py diff --git a/run.py b/run.py new file mode 100755 index 0000000..3549cbb --- /dev/null +++ b/run.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys +from whatmaps.command import run + +if __name__ == '__main__': + sys.exit(run()) diff --git a/whatmaps/command.py b/whatmaps/command.py index 74d85da..7c9b476 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -259,8 +259,4 @@ def main(argv): def run(): return(main(sys.argv)) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: -- cgit v1.2.3 From 4db63fee215535ba256b89a790df5dda09e756bd Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 26 Dec 2016 10:17:45 +0100 Subject: Be more specific about the type of error --- whatmaps/command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whatmaps/command.py b/whatmaps/command.py index 7c9b476..193cc9e 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -197,8 +197,8 @@ def main(argv): for pkg in pkgs: try: shared_objects += pkg.shared_objects - except PkgError: - logging.error("Cannot parse contents of %s - skipping it" % pkg.name) + except PkgError as e: + logging.error("%s - skipping package %s" % (e, pkg.name)) ret = 1 logging.debug("Found shared objects:") for so in shared_objects: -- cgit v1.2.3 From 365cae4479e50481ad0e0f5e914263dcae9e272b Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:07 +0100 Subject: distro: Discard stderr Otherwise it can mess up our parsing Closes: #1027317 --- whatmaps/distro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/distro.py b/whatmaps/distro.py index 87e264e..02a696c 100644 --- a/whatmaps/distro.py +++ b/whatmaps/distro.py @@ -130,7 +130,7 @@ def detect(): try: lsb_cmd = subprocess.Popen(['lsb_release', '--id', '-s'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.DEVNULL) output = lsb_cmd.communicate()[0] if not lsb_cmd.returncode: id = output.strip() -- cgit v1.2.3 From 7f974060a31cf366312bdf07c934712e1bc5ddad Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:07 +0100 Subject: distro: Look at the first line of LSB's output Debian outputs multiple lines nowadays --- whatmaps/distro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/distro.py b/whatmaps/distro.py index 02a696c..d4f991b 100644 --- a/whatmaps/distro.py +++ b/whatmaps/distro.py @@ -133,7 +133,7 @@ def detect(): stderr=subprocess.DEVNULL) output = lsb_cmd.communicate()[0] if not lsb_cmd.returncode: - id = output.strip() + id = output.decode().split('\n')[0].strip() except OSError: # id is None in this case pass -- cgit v1.2.3 From 319b847534900f4ab7ffb3334011b594b8af0540 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:08 +0100 Subject: Add Makefile for easy validation --- Makefile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dce5d92 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +check: + flake8 + nosetests3 -- cgit v1.2.3 From 5c9d0ef27bec7f21c35f3cf71bf0239c0710a44e Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:09 +0100 Subject: setup.cfg: Ignore line length and line break after operator Taken verbatim from gbp --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index aca3f68..673118a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,4 +3,5 @@ cover-package=whatmaps [flake8] # E501: ignore line length -ignore=E501 +# E265: block comment should start with '# ' +ignore=E501,E265,W504 \ No newline at end of file -- cgit v1.2.3 From 825ad6bc42a7fb92d9308653173a08484f8bcef2 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:09 +0100 Subject: redhatdistro: Fix doc comment --- whatmaps/redhatdistro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/redhatdistro.py b/whatmaps/redhatdistro.py index 4b17f3c..0f0c42d 100644 --- a/whatmaps/redhatdistro.py +++ b/whatmaps/redhatdistro.py @@ -23,7 +23,7 @@ from . rpmpkg import RpmPkg class RedHatDistro(Distro): - "RPM based distribution""" + """RPM based distribution""" _pkg_re = re.compile(r'(?P[\w\-\+]+)-(?P[\w\.]+)' '-(?P[\w\.]+)\.(?P.+)') -- cgit v1.2.3 From 61c850219fe25ac7ffd13f1473829528171dd35a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:10 +0100 Subject: Use raw strings This avoids escaping issues --- whatmaps/debianpkg.py | 2 +- whatmaps/redhatdistro.py | 2 +- whatmaps/rpmpkg.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/whatmaps/debianpkg.py b/whatmaps/debianpkg.py index 0192513..0e1301f 100644 --- a/whatmaps/debianpkg.py +++ b/whatmaps/debianpkg.py @@ -22,7 +22,7 @@ from . pkg import Pkg class DebianPkg(Pkg): type = 'Debian' - _init_script_re = re.compile('/etc/init.d/[\w\-\.]') + _init_script_re = re.compile(r'/etc/init.d/[\w\-\.]') _list_contents = ['dpkg-query', '-L', '${pkg_name}'] def __init__(self, name): diff --git a/whatmaps/redhatdistro.py b/whatmaps/redhatdistro.py index 0f0c42d..12336e6 100644 --- a/whatmaps/redhatdistro.py +++ b/whatmaps/redhatdistro.py @@ -25,7 +25,7 @@ from . rpmpkg import RpmPkg class RedHatDistro(Distro): """RPM based distribution""" _pkg_re = re.compile(r'(?P[\w\-\+]+)-(?P[\w\.]+)' - '-(?P[\w\.]+)\.(?P.+)') + r'-(?P[\w\.]+)\.(?P.+)') @classmethod def pkg(klass, name): diff --git a/whatmaps/rpmpkg.py b/whatmaps/rpmpkg.py index 493dd5a..3940931 100644 --- a/whatmaps/rpmpkg.py +++ b/whatmaps/rpmpkg.py @@ -22,7 +22,7 @@ from . pkg import Pkg class RpmPkg(Pkg): type = 'RPM' - _init_script_re = re.compile('/etc/rc.d/init.d/[\w\-\.]') + _init_script_re = re.compile(r'/etc/rc.d/init.d/[\w\-\.]') _list_contents = ['rpm', '-ql', '$pkg_name'] def __init__(self, name): -- cgit v1.2.3 From 179aa196cb974d0cac306dd614ebe2f10bbc04c1 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:10 +0100 Subject: command: Drop superfluous braces Make flake8 happy --- whatmaps/command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/command.py b/whatmaps/command.py index 193cc9e..70e0587 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -257,6 +257,6 @@ def main(argv): def run(): - return(main(sys.argv)) + return main(sys.argv) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: -- cgit v1.2.3 From 6e26ab39a0ed6e22e7a058952a185beb71cd993c Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:11 +0100 Subject: debiandistro: Clarify indentation --- whatmaps/debiandistro.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 57846ef..84ab9c8 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -119,10 +119,10 @@ class DebianDistro(Distro): aptconfig = sys.stdin.readline() if not aptconfig or aptconfig == '\n': break - if aptconfig.startswith('Whatmaps::Enable-Restart=') and \ - aptconfig.strip().split('=', 1)[1].lower() in ["true", "1"]: - logging.debug("Service restarts enabled") - whatmaps_enabled = True + if (aptconfig.startswith('Whatmaps::Enable-Restart=') and + aptconfig.strip().split('=', 1)[1].lower() in ["true", "1"]): + logging.debug("Service restarts enabled") + whatmaps_enabled = True if not whatmaps_enabled: return None -- cgit v1.2.3 From ae172c0b2d9b8383704bf9e6ac1be50d8e64d166 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:11 +0100 Subject: setup.py: Drop lsb check Otherwise we would also skip the check for /etc/debian-release which is more reliable these days. --- setup.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index 6cdf17b..69c36c8 100644 --- a/setup.py +++ b/setup.py @@ -20,18 +20,12 @@ from setuptools import setup data_files = [] -try: - import lsb_release - if (lsb_release.get_distro_information()['ID'] in ['Debian'] or - os.path.exists('/etc/debian_version')): - data_files = [('../etc/apt/apt.conf.d/', - ['apt/50whatmaps_apt']), - ('../etc/apt/apt.conf.d/', - ['apt/20services']), - ] -except ImportError: - pass - +if os.path.exists('/etc/debian_version'): + data_files = [('../etc/apt/apt.conf.d/', + ['apt/50whatmaps_apt']), + ('../etc/apt/apt.conf.d/', + ['apt/20services']), + ] setup(name="whatmaps", author='Guido Günther', -- cgit v1.2.3 From b13b3e407b3243c71989b4e9efb343e113dc9d85 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:07:12 +0100 Subject: debiandistro: Avoid lsb module Use /etc/debian_release directly as we don't have the lsb module in Debian anymore. --- whatmaps/debiandistro.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 84ab9c8..aaa981a 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -20,11 +20,6 @@ try: except ImportError: apt_pkg = None -try: - import lsb_release -except ImportError: - lsb_release = None - import logging import os import subprocess @@ -143,10 +138,8 @@ class DebianDistro(Distro): def _security_update_origins(klass): "Determine security update origins from apt configuration" - if lsb_release is None: - raise PkgError("lsb_release not found, can't determine security updates") - - codename = lsb_release.get_distro_information()['CODENAME'] + with open("/etc/debian_version") as f: + codename = f.read().strip() def _subst(line): mapping = {'distro_codename': codename, -- cgit v1.2.3 From e28c99d3fc7c391de039321e87b5ce12eae38572 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2022 13:09:19 +0100 Subject: Add NEWS Releases are rare these days, this gives us an idea what they were about. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 NEWS diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..d4b8e00 --- /dev/null +++ b/NEWS @@ -0,0 +1,5 @@ +whatmaps 0.0.13 +--------------- +Released December 2022 +* Run without lsb python modules +* Make flake8 happy -- cgit v1.2.3