diff options
-rw-r--r-- | setup.py | 3 | ||||
-rwxr-xr-x | whatmaps/command.py | 13 | ||||
-rw-r--r-- | whatmaps/debiandistro.py | 4 | ||||
-rw-r--r-- | whatmaps/process.py | 2 | ||||
-rw-r--r-- | whatmaps/systemd.py | 8 |
5 files changed, 21 insertions, 9 deletions
@@ -21,7 +21,8 @@ data_files = [] try: import lsb_release - if lsb_release.get_distro_information()['ID'] in [ 'Debian' ]: + 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/', diff --git a/whatmaps/command.py b/whatmaps/command.py index 7690ef8..d0f5c3e 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -39,7 +39,7 @@ def check_maps(procs, shared_objects): restart_procs[proc.exe] += [ proc ] else: restart_procs[proc.exe] = [ proc ] - continue + break return restart_procs @@ -59,7 +59,7 @@ def write_cmd_file(services, cmd_file, distro): out = open(cmd_file, 'w') print('#! /bin/sh', file=out) for service in services: - logging.debug("Need to restart %s", service) + logging.info("Need to restart '%s'", service) print(" ".join(distro.restart_service_cmd(service)), file=out) out.close() os.chmod(cmd_file, 0o755) @@ -113,7 +113,12 @@ def find_systemd_units(procmap, distro): for dummy, procs in procmap.items(): for proc in procs: - unit = Systemd.process_to_unit(proc) + try: + unit = Systemd.process_to_unit(proc) + except ValueError as e: + logging.warning("No systemd unit found for '%s': %s" + "- restart manually" % (proc.exe, e)) + continue if not unit: logging.warning("No systemd unit found for '%s'" "- restart manually" % proc.exe) @@ -225,7 +230,7 @@ def main(argv): write_cmd_file(services, options.print_cmds, distro) else: for service in services: - logging.info("Restarting %s" % service) + logging.info("Restarting '%s'" % service) distro.restart_service(service) elif services: print("Services that possibly need to be restarted:") diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 9294c9f..3a3bf16 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -31,12 +31,12 @@ import subprocess import sys import string -import whatmaps.distro +from . distro import Distro from . debianpkg import DebianPkg from . pkg import PkgError from . systemd import Systemd -class DebianDistro(whatmaps.distro.Distro): +class DebianDistro(Distro): "Debian (dpkg) based distribution" id = 'Debian' diff --git a/whatmaps/process.py b/whatmaps/process.py index 1abde23..23ed7ab 100644 --- a/whatmaps/process.py +++ b/whatmaps/process.py @@ -36,7 +36,7 @@ class Process(object): if m: self.exe = m.group('exe') self.deleted = True - logging.info("Using deleted exe %s", self.exe) + logging.debug("Using deleted exe %s", self.exe) if not os.path.exists(self.exe): logging.debug("%s doesn't exist", self.exe) self.cmdline = open(self._procpath('%d/cmdline' % self.pid)).read() diff --git a/whatmaps/systemd.py b/whatmaps/systemd.py index add6d0e..3407128 100644 --- a/whatmaps/systemd.py +++ b/whatmaps/systemd.py @@ -38,4 +38,10 @@ class Systemd(object): if systemctl_status.returncode: return None else: - return output.split()[0] + parts = output.split() + if parts[0].endswith('.service'): + return parts[0] + elif parts[1].endswith('.service'): + return parts[1] + else: + raise ValueError("Can't parse service name from\n%s" % output) |