1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-09 23:59:16 +00:00

fail if dynvariables cannot be executed successfully

This commit is contained in:
deadc0de6
2019-06-12 10:10:38 +02:00
parent 42f195d7c6
commit 6384516cdc
2 changed files with 12 additions and 3 deletions

View File

@@ -209,7 +209,12 @@ class CfgYaml:
# exec dynvariables # exec dynvariables
for k in dvar.keys(): for k in dvar.keys():
allvars[k] = shell(allvars[k]) ret, out = shell(allvars[k])
if not ret:
err = 'command \"{}\" failed: {}'.format(allvars[k], out)
self.log.error(err)
raise YamlException(err)
allvars[k] = out
if self.debug: if self.debug:
self.log.dbg('variables:') self.log.dbg('variables:')

View File

@@ -49,8 +49,12 @@ def write_to_tmpfile(content):
def shell(cmd): def shell(cmd):
"""run a command in the shell (expects a string)""" """
return subprocess.getoutput(cmd) run a command in the shell (expects a string)
returns True|False, output
"""
ret, out = subprocess.getstatusoutput(cmd)
return ret == 0, out
def diff(src, dst, raw=True, opts='', debug=False): def diff(src, dst, raw=True, opts='', debug=False):