Skip to content

Commit

Permalink
fix: random failings from subprocesses and command formatting (frappe…
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
gavindsouza authored Mar 2, 2020
1 parent ec1343c commit b064987
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions bench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -172,26 +173,11 @@ def setup_app(app):
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
Expand Down

0 comments on commit b064987

Please sign in to comment.