1
0
Fork 0

plugin_script: CWD to the script directory

This allows runnig helper scripts from the main script by just using
the current directory './' path, e.g. to run helper_script from main script:

  ./helper_script

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
Jaroslav Škarvada 2015-06-17 23:41:00 +02:00
parent 3987d03137
commit f4a7d1c71f

View file

@ -37,7 +37,8 @@ class ScriptPlugin(base.Plugin):
log.info("calling script '%s' with argument '%s'" % (script, argument))
log.debug("using environment '%s'" % str(environ.items()))
try:
proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ)
proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \
cwd = os.path.dirname(script))
out, err = proc.communicate()
if proc.returncode:
log.error("script '%s' error: %d, '%s'" % (script, proc.returncode, err[:-1]))