From 630858eb968616edb8eebcb72dfb15419fefe2cc Mon Sep 17 00:00:00 2001 From: Shridhar Patil Date: Mon, 23 Jul 2018 14:35:17 +0530 Subject: [PATCH] bench use should check if the site exists (#5849) * bench use should check if the site exists * check site path while running use site --- frappe/commands/site.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 1a44a7dc01..5ec3db3cb9 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -277,8 +277,11 @@ def _use(site, sites_path='.'): use(site, sites_path=sites_path) def use(site, sites_path='.'): - with open(os.path.join(sites_path, "currentsite.txt"), "w") as sitefile: - sitefile.write(site) + if os.path.exists(os.path.join(sites_path, site)): + with open(os.path.join(sites_path, "currentsite.txt"), "w") as sitefile: + sitefile.write(site) + else: + print("{} does not exist".format(site)) @click.command('backup') @click.option('--with-files', default=False, is_flag=True, help="Take backup with files")