aboutsummaryrefslogtreecommitdiff
path: root/whatmaps
diff options
context:
space:
mode:
Diffstat (limited to 'whatmaps')
-rwxr-xr-xwhatmaps/command.py6
-rw-r--r--whatmaps/debiandistro.py19
-rw-r--r--whatmaps/debianpkg.py2
-rw-r--r--whatmaps/distro.py4
-rw-r--r--whatmaps/redhatdistro.py4
-rw-r--r--whatmaps/rpmpkg.py2
6 files changed, 15 insertions, 22 deletions
diff --git a/whatmaps/command.py b/whatmaps/command.py
index 7c9b476..70e0587 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:
@@ -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\:·:
diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py
index 57846ef..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
@@ -119,10 +114,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
@@ -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,
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/distro.py b/whatmaps/distro.py
index 87e264e..d4f991b 100644
--- a/whatmaps/distro.py
+++ b/whatmaps/distro.py
@@ -130,10 +130,10 @@ 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()
+ id = output.decode().split('\n')[0].strip()
except OSError:
# id is None in this case
pass
diff --git a/whatmaps/redhatdistro.py b/whatmaps/redhatdistro.py
index 4b17f3c..12336e6 100644
--- a/whatmaps/redhatdistro.py
+++ b/whatmaps/redhatdistro.py
@@ -23,9 +23,9 @@ from . rpmpkg import RpmPkg
class RedHatDistro(Distro):
- "RPM based distribution"""
+ """RPM based distribution"""
_pkg_re = re.compile(r'(?P<pkg>[\w\-\+]+)-(?P<ver>[\w\.]+)'
- '-(?P<rel>[\w\.]+)\.(?P<arch>.+)')
+ r'-(?P<rel>[\w\.]+)\.(?P<arch>.+)')
@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):