commit: 8b6bca504dd7ef66426c50f8d510987021f872ad
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 16 00:37:10 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Sep 16 00:37:10 2015 +0000
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=8b6bca50
grs/Execute.py: allow running of a cmd in a shell.
grs/Execute.py | 12 ++++++++----
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)