-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor: pep8 cleanup, just warn, no exit with an error
- Loading branch information
Mark Fiers
committed
Nov 11, 2012
1 parent
6fec2da
commit d1c719e
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|