feat: Set default site using FRAPPE_SITE env var

Default site can now be set using the environment variable FRAPPE_SITE
An attempt to deprecate the use of currentsite.txt
This commit is contained in:
Faris Ansari 2021-02-04 22:19:39 +05:30
parent 40d3db402a
commit b181b69894
2 changed files with 9 additions and 0 deletions

View file

@ -382,3 +382,10 @@ class TestCommands(BaseTestCommands):
os.remove(test1_path)
os.remove(test2_path)
def test_frappe_site_env(self):
os.putenv('FRAPPE_SITE', frappe.local.site)
self.execute("bench execute frappe.ping")
self.assertEquals(self.returncode, 0)
self.assertIn("pong", self.stdout)

View file

@ -54,6 +54,8 @@ def get_sites(site_arg):
return frappe.utils.get_sites()
elif site_arg:
return [site_arg]
elif os.environ.get('FRAPPE_SITE'):
return [os.environ.get('FRAPPE_SITE')]
elif os.path.exists('currentsite.txt'):
with open('currentsite.txt') as f:
site = f.read().strip()