From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 017451393F1 for ; Wed, 16 Sep 2015 00:32:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8878DE07DD; Wed, 16 Sep 2015 00:32:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2A3F1E07DD for ; Wed, 16 Sep 2015 00:32:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E69D0340C33 for ; Wed, 16 Sep 2015 00:32:33 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 51AF51F3 for ; Wed, 16 Sep 2015 00:32:31 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1442363830.8b6bca504dd7ef66426c50f8d510987021f872ad.blueness@gentoo> Subject: [gentoo-commits] proj/grss:master commit in: grs/ X-VCS-Repository: proj/grss X-VCS-Files: grs/Execute.py grs/ISOIt.py X-VCS-Directories: grs/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 8b6bca504dd7ef66426c50f8d510987021f872ad X-VCS-Branch: master Date: Wed, 16 Sep 2015 00:32:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a9dbcd21-d45d-4afd-b625-c5a8e79e1182 X-Archives-Hash: c48aaedbaee1eec5b0144c41920fb742 commit: 8b6bca504dd7ef66426c50f8d510987021f872ad Author: Anthony G. Basile gentoo org> AuthorDate: Wed Sep 16 00:37:10 2015 +0000 Commit: Anthony G. Basile gentoo 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)