mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Support executing commands in a specific cwd
Simply plumbed through to Popen(), which already supports this. Change-Id: If1fdf0a33c96f3aad42407fdc7c9c9f7d4b95c00
This commit is contained in:
parent
a9a5be7717
commit
19240dc201
1 changed files with 4 additions and 4 deletions
|
@ -1,12 +1,12 @@
|
||||||
def log_check_call(command, stdin=None, env=None, shell=False):
|
def log_check_call(command, stdin=None, env=None, shell=False, cwd=None):
|
||||||
status, stdout, stderr = log_call(command, stdin, env, shell)
|
status, stdout, stderr = log_call(command, stdin, env, shell, cwd)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
raise CalledProcessError(status, ' '.join(command), '\n'.join(stderr))
|
raise CalledProcessError(status, ' '.join(command), '\n'.join(stderr))
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
def log_call(command, stdin=None, env=None, shell=False):
|
def log_call(command, stdin=None, env=None, shell=False, cwd=None):
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
from multiprocessing.dummy import Pool as ThreadPool
|
from multiprocessing.dummy import Pool as ThreadPool
|
||||||
|
@ -16,7 +16,7 @@ def log_call(command, stdin=None, env=None, shell=False):
|
||||||
log = logging.getLogger(__name__ + command_log)
|
log = logging.getLogger(__name__ + command_log)
|
||||||
log.debug('Executing: {command}'.format(command=' '.join(command)))
|
log.debug('Executing: {command}'.format(command=' '.join(command)))
|
||||||
|
|
||||||
process = subprocess.Popen(args=command, env=env, shell=shell,
|
process = subprocess.Popen(args=command, env=env, shell=shell, cwd=cwd,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
|
|
Loading…
Add table
Reference in a new issue