Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5419105f90
Fetching contributors…

Cannot retrieve contributors at this time

executable file 29 lines (21 sloc) 0.541 kb
#!/usr/bin/env python2.7
import subprocess
def shell(*command):
"""Run a shell command, returning stdout as an array of strings.
>>> shell("echo", "hello")
['hello\n']
"""
try:
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError as e:
if e.errno == 2: # No such file or directory
raise IOError('Cannot run ' + ' '.join(command))
raw, _ = p.communicate()
res = []
for line in raw.split('\n'):
if len(line) > 0:
# yield line
res.append(line)
return res
Jump to Line
Something went wrong with that request. Please try again.