def call(command): try: output = proc_call(command) except CalledProcessError as e: output = e.output if output: print('Executing','"%s":' % ' '.join(command)) for line in output.splitlines(): print(' ',line.decode())
def call(command): try: output = proc_call(command) except CalledProcessError as e: output = e.output if output: print('Executing', '"%s":' % ' '.join(command)) for line in output.splitlines(): print(' ', line.decode())
def call_subprocess(cmd, **kw): try: from subprocess import proc_call except ImportError: # no subprocess for Python 2.3 def proc_call(cmd, **kwargs): cwd = kwargs.get('cwd', '.') old_cwd = os.getcwd() try: os.chdir(cwd) return os.system(' '.join(cmd)) finally: os.chdir(old_cwd) cwd = kw.get('cwd', '.') cmd_desc = ' '.join(cmd) log.info('Running "%s" in %s' % (cmd_desc, cwd)) returncode = proc_call(cmd, **kw) if returncode: raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
def cmd(*args): cmd_line = list(head) cmd_line.extend(args) print(cmd_line) proc_call(cmd_line)