diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2010-04-21 10:46:39 -0500 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-04-21 10:47:40 -0500 |
commit | eee7a1c12e7924fd50ee63ab9e3f1a0c8b5e2c09 (patch) | |
tree | 72efc91cd175fb92945665d66bfa50e4ba5335f1 /src | |
parent | c688c4592be717cb28dabd13d6441c4c7c5bca06 (diff) | |
download | bcfg2-eee7a1c12e7924fd50ee63ab9e3f1a0c8b5e2c09.tar.gz bcfg2-eee7a1c12e7924fd50ee63ab9e3f1a0c8b5e2c09.tar.bz2 bcfg2-eee7a1c12e7924fd50ee63ab9e3f1a0c8b5e2c09.zip |
Upstart: Fix traceback for services that don't exist
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Tools/Upstart.py | 26 |
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 |