mirror of
https://github.com/frappe/bench.git
synced 2025-02-12 23:58:25 +00:00
[fix] don't use async if invoked from command line
This commit is contained in:
parent
9065066b8f
commit
05b8d22f44
@ -63,9 +63,9 @@ def new_app(app, bench='.'):
|
|||||||
apps = os.path.abspath(os.path.join(bench, 'apps'))
|
apps = os.path.abspath(os.path.join(bench, 'apps'))
|
||||||
if FRAPPE_VERSION == 4:
|
if FRAPPE_VERSION == 4:
|
||||||
exec_cmd("{frappe} --make_app {apps} {app}".format(frappe=get_frappe(bench=bench),
|
exec_cmd("{frappe} --make_app {apps} {app}".format(frappe=get_frappe(bench=bench),
|
||||||
apps=apps, app=app), async=False)
|
apps=apps, app=app))
|
||||||
else:
|
else:
|
||||||
run_frappe_cmd('make-app', apps, app, bench=bench, async=False)
|
run_frappe_cmd('make-app', apps, app, bench=bench)
|
||||||
install_app(app, bench=bench)
|
install_app(app, bench=bench)
|
||||||
|
|
||||||
def install_app(app, bench='.'):
|
def install_app(app, bench='.'):
|
||||||
|
@ -31,10 +31,14 @@ import grp
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
logger = logging.getLogger('bench')
|
logger = logging.getLogger('bench')
|
||||||
|
from_command_line = False
|
||||||
|
|
||||||
global FRAPPE_VERSION
|
global FRAPPE_VERSION
|
||||||
|
|
||||||
def cli():
|
def cli():
|
||||||
|
global from_command_line
|
||||||
|
from_command_line = True
|
||||||
|
|
||||||
check_uid()
|
check_uid()
|
||||||
change_dir()
|
change_dir()
|
||||||
change_uid()
|
change_uid()
|
||||||
|
@ -83,7 +83,10 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
|||||||
generate_redis_cache_config(bench=path)
|
generate_redis_cache_config(bench=path)
|
||||||
generate_redis_async_broker_config(bench=path)
|
generate_redis_async_broker_config(bench=path)
|
||||||
|
|
||||||
def exec_cmd(cmd, cwd='.', async=True):
|
def exec_cmd(cmd, cwd='.'):
|
||||||
|
from .cli import from_command_line
|
||||||
|
|
||||||
|
async = False if from_command_line else True
|
||||||
if async:
|
if async:
|
||||||
stderr = stdout = subprocess.PIPE
|
stderr = stdout = subprocess.PIPE
|
||||||
else:
|
else:
|
||||||
@ -462,11 +465,14 @@ def get_current_frappe_version(bench='.'):
|
|||||||
return fv(bench=bench)
|
return fv(bench=bench)
|
||||||
|
|
||||||
def run_frappe_cmd(*args, **kwargs):
|
def run_frappe_cmd(*args, **kwargs):
|
||||||
|
from .cli import from_command_line
|
||||||
|
|
||||||
bench = kwargs.get('bench', '.')
|
bench = kwargs.get('bench', '.')
|
||||||
f = get_env_cmd('python', bench=bench)
|
f = get_env_cmd('python', bench=bench)
|
||||||
sites_dir = os.path.join(bench, 'sites')
|
sites_dir = os.path.join(bench, 'sites')
|
||||||
|
|
||||||
if kwargs.get('async'):
|
async = False if from_command_line else True
|
||||||
|
if async:
|
||||||
stderr = stdout = subprocess.PIPE
|
stderr = stdout = subprocess.PIPE
|
||||||
else:
|
else:
|
||||||
stderr = stdout = None
|
stderr = stdout = None
|
||||||
@ -474,7 +480,7 @@ def run_frappe_cmd(*args, **kwargs):
|
|||||||
p = subprocess.Popen((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args,
|
p = subprocess.Popen((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args,
|
||||||
cwd=sites_dir, stdout=stdout, stderr=stderr)
|
cwd=sites_dir, stdout=stdout, stderr=stderr)
|
||||||
|
|
||||||
if kwargs.get('async'):
|
if async:
|
||||||
return_code = print_output(p)
|
return_code = print_output(p)
|
||||||
else:
|
else:
|
||||||
return_code = p.wait()
|
return_code = p.wait()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user