aboutsummaryrefslogtreecommitdiff
path: root/grs
diff options
context:
space:
mode:
Diffstat (limited to 'grs')
-rw-r--r--grs/Execute.py12
-rw-r--r--grs/ISOIt.py4
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)