Skip to content

Commit

Permalink
better handling of RC
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Jul 18, 2012
1 parent ead2afc commit 75e1011
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions lib/python/moa/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,20 @@ def execute(self, job, args, **kwargs):

#unless command == 'run' - just execute it and return the RC
if command != 'run':
l.debug("Simple execute of '%s'" % command)
sysConf.rc = self.backend.execute(self, command, args)
self.finishExecute()
return sysConf.rc
l.debug("Simple type execute of '%s'" % command)
rc = self.backend.execute(self, command, args)
sysConf.rc = rc
if rc != 0:
sysConf.pluginHandler.run("post_error")
moa.ui.exitError("Error running")
return rc

# command == 'run' is a special case - this will trigger a series of
# runs.

l.debug("Starting RUN")
for subcommand in ['prepare', 'run', 'finish']:
self.pluginHandler.run("pre_%s" % subcommand)
l.debug("Starting RUN/%s" % subcommand)
try:
rc = self.backend.execute(self, subcommand, args)
Expand All @@ -297,7 +301,7 @@ def execute(self, job, args, **kwargs):
if rc != 0:
sysConf.rc = rc
sysConf.pluginHandler.run("post_error")
return rc
moa.ui.exitError("Exit on error")
except moa.exceptions.MoaCommandDoesNotExist:
l.debug("%s step is not present" % subcommand)

Expand Down Expand Up @@ -372,6 +376,21 @@ def defineCommands(self, commandparser):
"""
parser, cparser = moa.args.getParser()

if self.hasCommand('unittest'):
# this does not have to be defined in the .moa - if it is here
# we'll register it
hlp = 'run unittest for this template'
cp = cparser.add_parser(
'unittest', help=hlp)

sysConf.commands['unittest'] = {
'desc' : hlp,
'long' : hlp,
'source' : 'template',
'recursive' : 'global',
'needsJob' : True,
'call' : self.execute }

for c in self.template.commands:
cinf = self.template.commands[c]
hlp = cinf.get('help', '').strip()
Expand Down

0 comments on commit 75e1011

Please sign in to comment.