Skip to content

Commit

Permalink
minor: pep8 cleanup, just warn, no exit with an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Nov 11, 2012
1 parent 6fec2da commit d1c719e
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions moa/plugin/system/varInject.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# Copyright 2009-2011 Mark Fiers
# The New Zealand Institute for Plant & Food Research
#
#
# This file is part of Moa - http://github.com/mfiers/Moa
#
#
# Licensed under the GPL license (see 'COPYING')
#
#
"""
**varInject** - Inject variables into this job
----------------------------------------------
"""
import os
import sys
import subprocess as sp

from moa.sysConf import sysConf
import moa.logger as l
import moa.logger
import moa.ui

l = moa.logger.getLogger(__name__)


def hook_prepare_3():
job = sysConf.job
job.template.parameters.var_inject = {
'category' : 'advanced',
'optional' : True,
'help' : 'The output of this command is parsed and injected into the config',
'recursive' : False,
'type' : 'string'

'category': 'advanced',
'optional': True,
'help': ('The output of this command is parsed and injected ' +
'into the job configuration'),
'recursive': False,
'type': 'string'
}

}

renderedConf = job.conf.render()
renderedConf = job.conf.render()
injectcommand = renderedConf.get('var_inject', '')

if not injectcommand:
return

P = sp.Popen(injectcommand, shell=True, stdout=sp.PIPE)
out, err = P.communicate()
if err or P.returncode != 0:
moa.ui.exitError("var_inject returned an error")
for line in out.split("\n"):
ls = line.strip().split(None, 1)
if not ls: continue
if not ls:
continue
if len(ls) != 2:
moa.ui.exitError("var_inject invalid return: %s" % line)
k,v = ls
moa.ui.warning("var_inject invalid return: %s" % line)
k, v = ls
job.conf[k] = v

0 comments on commit d1c719e

Please sign in to comment.