diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-05-02 17:28:38 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-06-28 21:34:51 +0200 |
commit | e1b9e7fe3b1fa6b6e829f7eb5787b67d9894cfd1 (patch) | |
tree | 80c713e5c54872f286cb38c4f726a2377b498c80 /whatmaps/debiandistro.py | |
parent | ac817c1fc37bd7e831b33f32028005b612eb76eb (diff) |
pkg_services: Check if a service is actually installed
So far we returned the full list from pkg_services. This is o.k. for
many to one mappings like apache but not for one to many like openjdk.
To avoid to print out services that aren't installed check that
beforehand.
Diffstat (limited to 'whatmaps/debiandistro.py')
-rw-r--r-- | whatmaps/debiandistro.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 4a3d0db..3a47d50 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -26,7 +26,7 @@ except ImportError: lsb_release = None import logging -import string +import os import subprocess import sys @@ -35,7 +35,7 @@ from . debianpkg import DebianPkg from . pkg import PkgError class DebianDistro(Distro): - "Debian (dpkg) based distribution""" + "Debian (dpkg) based distribution" id = 'Debian' _pkg_services = { 'apache2-mpm-worker': [ 'apache2' ], @@ -73,9 +73,15 @@ class DebianDistro(Distro): @classmethod def restart_service_cmd(klass, name): + """The command that should be used to start a service""" return ['invoke-rc.d', name, 'restart'] @classmethod + def is_service_installed(klass, name): + """Whether the system has this service""" + return os.path.exists('/etc/init.d/%s' % name) + + @classmethod def has_apt(klass): return True |