2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-24 04:59:01 +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:
gavin 2020-03-02 19:32:25 +05:30 committed by GitHub
parent ec1343c0fa
commit b0649870ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ class color:
green = '\033[92m'
yellow = '\033[93m'
red = '\033[91m'
silver = '\033[90m'
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)
def exec_cmd(cmd, cwd='.'):
from .cli import from_command_line
is_async = False if from_command_line else True
if is_async:
stderr = stdout = subprocess.PIPE
else:
stderr = stdout = None
import shlex
logger.info(cmd)
p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr,
universal_newlines=True)
if is_async:
return_code = print_output(p)
else:
return_code = p.wait()
if return_code > 0:
raise CommandFailedError(cmd)
cmd = shlex.split(cmd)
print("{0}$ {1}{2}".format(color.silver, cmd, color.nc))
subprocess.call(cmd, cwd=cwd, universal_newlines=True)
def which(executable, raise_err = False):
from distutils.spawn import find_executable