Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #6 from dcolligan/4_shell_true
Browse files Browse the repository at this point in the history
Add shell=True option to runCommand
  • Loading branch information
dcolligan authored Oct 19, 2016
2 parents 42e2362 + 02a5337 commit 1f2815e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ga4gh_common/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def runTests(self):
testCommands = self.parseTestCommands()
for command in testCommands:
self.log('Running: "{}"'.format(command))
utils.runCommand(command)
utils.runCommand(command, shell=True)
self.log('SUCCESS')

def log(self, logStr):
Expand Down
11 changes: 6 additions & 5 deletions ga4gh_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,25 @@ def ga4ghImportGlue():
sys.path.append(path)


def runCommand(command, silent=False):
def runCommand(command, silent=False, shell=False):
"""
Run a shell command
"""
splits = shlex.split(command)
runCommandSplits(splits, silent=silent)
runCommandSplits(splits, silent=silent, shell=shell)


def runCommandSplits(splits, silent=False):
def runCommandSplits(splits, silent=False, shell=False):
"""
Run a shell command given the command's parsed command line
"""
try:
if silent:
with open(os.devnull, 'w') as devnull:
subprocess.check_call(splits, stdout=devnull, stderr=devnull)
subprocess.check_call(
splits, stdout=devnull, stderr=devnull, shell=shell)
else:
subprocess.check_call(splits)
subprocess.check_call(splits, shell=shell)
except OSError, e:
if e.errno == 2: # cmd not found
raise Exception(
Expand Down

0 comments on commit 1f2815e

Please sign in to comment.