mirror of
https://github.com/frappe/bench.git
synced 2025-01-23 15:08:24 +00:00
fix: "faster" get_sites function
chore: dropped unused get_sites_dir function style: pythonic "is not" usage
This commit is contained in:
parent
a3dc9e69b7
commit
8764813121
@ -139,7 +139,7 @@ def shell(bench_path='.'):
|
||||
def backup_site(site):
|
||||
"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')
|
||||
sys.exit(1)
|
||||
backup_site(site, bench_path='.')
|
||||
|
@ -209,17 +209,8 @@ def build_assets(bench_path='.', app=None):
|
||||
|
||||
def get_sites(bench_path='.'):
|
||||
sites_path = os.path.join(bench_path, 'sites')
|
||||
sites = []
|
||||
for site in os.listdir(sites_path):
|
||||
path = os.path.join(sites_path, site)
|
||||
if (os.path.isdir(path)
|
||||
and not os.path.islink(path)
|
||||
and os.path.exists(os.path.join(path, 'site_config.json'))):
|
||||
sites.append(site)
|
||||
return sorted(sites)
|
||||
|
||||
def get_sites_dir(bench_path='.'):
|
||||
return os.path.abspath(os.path.join(bench_path, 'sites'))
|
||||
sites = (site for site in os.listdir(sites_path) if os.path.exists(os.path.join(sites_path, site, 'site_config.json')))
|
||||
return sites
|
||||
|
||||
def get_bench_dir(bench_path='.'):
|
||||
return os.path.abspath(bench_path)
|
||||
@ -425,7 +416,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))
|
||||
|
||||
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")
|
||||
exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench_path=bench_path), site=site),
|
||||
cwd=os.path.join(bench_path, 'sites'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user