mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
fix: random failings from subprocesses and command formatting (#935)
* fix: random failings from subprocesses async executions of muliple processes leads to various errors. eg: get-app operation runs a "git clone" at the same time "pip install" is run. This causes failures as the folder either doesnt exist or isnt complete. Proposed solution to this is to execute blocking subprocesseses * style: command logging format via exec_cmd
This commit is contained in:
parent
ec1343c0fa
commit
b0649870ee
@ -28,6 +28,7 @@ class color:
|
|||||||
green = '\033[92m'
|
green = '\033[92m'
|
||||||
yellow = '\033[93m'
|
yellow = '\033[93m'
|
||||||
red = '\033[91m'
|
red = '\033[91m'
|
||||||
|
silver = '\033[90m'
|
||||||
|
|
||||||
|
|
||||||
def is_bench_directory(directory=os.path.curdir):
|
def is_bench_directory(directory=os.path.curdir):
|
||||||
@ -172,26 +173,11 @@ def clone_apps_from(bench_path, clone_from, update_app=True):
|
|||||||
setup_app(app)
|
setup_app(app)
|
||||||
|
|
||||||
def exec_cmd(cmd, cwd='.'):
|
def exec_cmd(cmd, cwd='.'):
|
||||||
from .cli import from_command_line
|
import shlex
|
||||||
|
|
||||||
is_async = False if from_command_line else True
|
|
||||||
if is_async:
|
|
||||||
stderr = stdout = subprocess.PIPE
|
|
||||||
else:
|
|
||||||
stderr = stdout = None
|
|
||||||
|
|
||||||
logger.info(cmd)
|
logger.info(cmd)
|
||||||
|
cmd = shlex.split(cmd)
|
||||||
p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr,
|
print("{0}$ {1}{2}".format(color.silver, cmd, color.nc))
|
||||||
universal_newlines=True)
|
subprocess.call(cmd, cwd=cwd, universal_newlines=True)
|
||||||
|
|
||||||
if is_async:
|
|
||||||
return_code = print_output(p)
|
|
||||||
else:
|
|
||||||
return_code = p.wait()
|
|
||||||
|
|
||||||
if return_code > 0:
|
|
||||||
raise CommandFailedError(cmd)
|
|
||||||
|
|
||||||
def which(executable, raise_err = False):
|
def which(executable, raise_err = False):
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
|
Loading…
Reference in New Issue
Block a user