2 from subprocess import CalledProcessError
6 """An advanced shell, with the ability to do dry-run and log commands"""
7 def __init__(self, verbose = False, dry = False):
8 """ `verbose` Whether or not to print the command and outputs
9 `dry` Whether or not to not run any commands, and just print"""
10 self.verbose = verbose
12 def call(self, *args):
13 if self.dry or self.verbose:
14 print "$ " + ' '.join(args)
18 proc = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr)
20 proc = subprocess.Popen(args)
23 raise CalledProcessError(proc.returncode, args)