summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-12-28 15:04:15 +0100
committerGuido Günther <agx@sigxcpu.org>2014-12-28 15:04:15 +0100
commitffc774e01dc6651d0d74e475b1dc7fac44d43788 (patch)
tree0c19a2131090c65ac8f71165b2338081b315b266
parent36fd4eee614a35fece4ccc085af73d92ce5de2a4 (diff)
parent1ee865fefdd5267c2ada84cc370f2005b6b1a5b6 (diff)
Merge tag 'v0.0.9' into debian/master
whatmaps v0.0.9
-rw-r--r--setup.py3
-rwxr-xr-xwhatmaps/command.py13
-rw-r--r--whatmaps/debiandistro.py4
-rw-r--r--whatmaps/process.py2
-rw-r--r--whatmaps/systemd.py8
5 files changed, 21 insertions, 9 deletions
diff --git a/setup.py b/setup.py
index 7e7ed00..cdadd50 100644
--- a/setup.py
+++ b/setup.py
@@ -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)