mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 07:28:25 +00:00
fix(cli): give warn that commands are not executed in a bench folder
This commit is contained in:
parent
bb7310f218
commit
ef1a624556
@ -1,6 +1,6 @@
|
|||||||
import click
|
import click
|
||||||
import os, sys, logging, json, pwd, subprocess
|
import os, sys, logging, json, pwd, subprocess
|
||||||
from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe
|
from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log
|
||||||
from bench.app import get_apps
|
from bench.app import get_apps
|
||||||
from bench.config.common_site_config import get_config
|
from bench.config.common_site_config import get_config
|
||||||
from bench.commands import bench_command
|
from bench.commands import bench_command
|
||||||
@ -43,7 +43,7 @@ def cli():
|
|||||||
|
|
||||||
def check_uid():
|
def check_uid():
|
||||||
if cmd_requires_root() and not is_root():
|
if cmd_requires_root() and not is_root():
|
||||||
print('superuser privileges required for this command')
|
log('superuser privileges required for this command', level=3)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def cmd_requires_root():
|
def cmd_requires_root():
|
||||||
@ -71,7 +71,7 @@ def change_uid():
|
|||||||
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
|
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
|
||||||
os.environ['HOME'] = pwd.getpwnam(frappe_user).pw_dir
|
os.environ['HOME'] = pwd.getpwnam(frappe_user).pw_dir
|
||||||
else:
|
else:
|
||||||
print('You should not run this command as root')
|
log('You should not run this command as root', level=3)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def old_frappe_cli(bench_path='.'):
|
def old_frappe_cli(bench_path='.'):
|
||||||
@ -93,6 +93,7 @@ def get_frappe_commands(bench_path='.'):
|
|||||||
python = get_env_cmd('python', bench_path=bench_path)
|
python = get_env_cmd('python', bench_path=bench_path)
|
||||||
sites_path = os.path.join(bench_path, 'sites')
|
sites_path = os.path.join(bench_path, 'sites')
|
||||||
if not os.path.exists(sites_path):
|
if not os.path.exists(sites_path):
|
||||||
|
log("WARN: Command not being executed in bench directory", level=3)
|
||||||
return []
|
return []
|
||||||
try:
|
try:
|
||||||
output = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path)
|
output = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user