diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2015-09-15 20:37:10 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-09-15 20:37:10 -0400 |
commit | 8b6bca504dd7ef66426c50f8d510987021f872ad (patch) | |
tree | d538674abbbb5b2967e469529c1da3b33f24586a | |
parent | grs/Interpret.py: fix medium_type for hashit. (diff) | |
download | grss-8b6bca504dd7ef66426c50f8d510987021f872ad.tar.gz grss-8b6bca504dd7ef66426c50f8d510987021f872ad.tar.bz2 grss-8b6bca504dd7ef66426c50f8d510987021f872ad.zip |
grs/Execute.py: allow running of a cmd in a shell.
-rw-r--r-- | grs/Execute.py | 12 | ||||
-rw-r--r-- | grs/ISOIt.py | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/grs/Execute.py b/grs/Execute.py index 25f618f..32286ec 100644 --- a/grs/Execute.py +++ b/grs/Execute.py @@ -27,7 +27,8 @@ from grs.Constants import CONST class Execute(): """ Execute a shell command """ - def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, logfile = CONST.LOGFILE): + def __init__(self, cmd, timeout = 1, extra_env = {}, failok = False, shell = False \ + logfile = CONST.LOGFILE): """ Execute a shell command. cmd - Simple string of the command to be execute as a @@ -54,15 +55,18 @@ class Execute(): except ProcessLookupError: pass - args = shlex.split(cmd) + if shell: + args = cmd + else: + args = shlex.split(cmd) extra_env = dict(os.environ, **extra_env) if logfile: f = open(logfile, 'a') - proc = subprocess.Popen(args, stdout=f, stderr=f, env=extra_env) + proc = subprocess.Popen(args, stdout=f, stderr=f, env=extra_env, shell=shell) else: f = sys.stderr - proc = subprocess.Popen(args, env=extra_env) + proc = subprocess.Popen(args, env=extra_env, shell=shell) try: proc.wait(timeout) diff --git a/grs/ISOIt.py b/grs/ISOIt.py index ff63506..49b97bf 100644 --- a/grs/ISOIt.py +++ b/grs/ISOIt.py @@ -93,8 +93,8 @@ class ISOIt(HashIt): cwd = os.getcwd() os.chdir(initramfs_root) cmd = 'find . -print | cpio -H newc -o | gzip -9 > %s' % initramfs_path - # Can't pipe commands, so we'll have to find another way - #Execute(cmd, timeout=600, logfile=self.logfile) + # Piped commands must be run in a shell. + Execute(cmd, timeout=600, logfile=self.logfile, shell=True) os.chdir(cwd) |