summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Client/Tools/Upstart.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lib/Client/Tools/Upstart.py b/src/lib/Client/Tools/Upstart.py
index 43a51fd79..1fc80a1db 100644
--- a/src/lib/Client/Tools/Upstart.py
+++ b/src/lib/Client/Tools/Upstart.py
@@ -31,18 +31,24 @@ class Upstart(Bcfg2.Client.Tools.SvcTool):
'''
output = self.cmd.run('/usr/sbin/service %s status' % \
entry.get('name'))[1][0]
- if output.split(' ')[1].split('/')[1].startswith('running'):
- entry.set('current_status', 'on')
- if entry.get('status') == 'off':
- status = False
+ try:
+ running = output.split(' ')[1].split('/')[1].startswith('running')
+ if running:
+ entry.set('current_status', 'on')
+ if entry.get('status') == 'off':
+ status = False
+ else:
+ status = True
else:
- status = True
- else:
+ entry.set('current_status', 'off')
+ if entry.get('status') == 'on':
+ status = False
+ else:
+ status = True
+ except IndexError:
+ # service does not exist
entry.set('current_status', 'off')
- if entry.get('status') == 'on':
- status = False
- else:
- status = True
+ status = False
return status