2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

Merge pull request #857 from developmentforpeople/fix-get-sites-as-frappe

fix: bench.get_sites now do same checks to validate a site folder like frappe.utils.get_sites
This commit is contained in:
gavin 2020-01-03 15:11:20 +05:30 committed by GitHub
commit 9559fe0c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -139,7 +139,7 @@ def shell(bench_path='.'):
def backup_site(site): def backup_site(site):
"backup site" "backup site"
from bench.utils import get_sites, backup_site from bench.utils import get_sites, backup_site
if not site in get_sites(bench_path='.'): if site not in get_sites(bench_path='.'):
print('site not found') print('site not found')
sys.exit(1) sys.exit(1)
backup_site(site, bench_path='.') backup_site(site, bench_path='.')

View File

@ -220,14 +220,10 @@ def build_assets(bench_path='.', app=None):
exec_cmd(command, cwd=bench_path) exec_cmd(command, cwd=bench_path)
def get_sites(bench_path='.'): def get_sites(bench_path='.'):
sites_dir = os.path.join(bench_path, "sites") sites_path = os.path.join(bench_path, 'sites')
sites = [site for site in os.listdir(sites_dir) sites = (site for site in os.listdir(sites_path) if os.path.exists(os.path.join(sites_path, site, 'site_config.json')))
if os.path.isdir(os.path.join(sites_dir, site)) and site not in ('assets',)]
return sites return sites
def get_sites_dir(bench_path='.'):
return os.path.abspath(os.path.join(bench_path, 'sites'))
def get_bench_dir(bench_path='.'): def get_bench_dir(bench_path='.'):
return os.path.abspath(bench_path) return os.path.abspath(bench_path)
@ -441,7 +437,7 @@ def restart_systemd_processes(bench_path='.', web_workers=False):
exec_cmd('sudo systemctl start -- $(systemctl show -p Requires {bench_name}.target | cut -d= -f2)'.format(bench_name=bench_name)) exec_cmd('sudo systemctl start -- $(systemctl show -p Requires {bench_name}.target | cut -d= -f2)'.format(bench_name=bench_name))
def set_default_site(site, bench_path='.'): def set_default_site(site, bench_path='.'):
if not site in get_sites(bench_path=bench_path): if site not in get_sites(bench_path=bench_path):
raise Exception("Site not in bench") raise Exception("Site not in bench")
exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench_path=bench_path), site=site), exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench_path=bench_path), site=site),
cwd=os.path.join(bench_path, 'sites')) cwd=os.path.join(bench_path, 'sites'))