2020-02-20 06:38:51 +00:00
|
|
|
import sys
|
|
|
|
import frappe
|
|
|
|
import IPython
|
|
|
|
|
|
|
|
from frappe.utils import get_sites
|
|
|
|
|
|
|
|
|
|
|
|
def console(site):
|
|
|
|
"Start ipython console for a site"
|
|
|
|
if site not in get_sites():
|
|
|
|
print("Site {0} does not exist on the current bench".format(site))
|
|
|
|
return
|
|
|
|
|
|
|
|
frappe.init(site=site)
|
|
|
|
frappe.connect()
|
|
|
|
frappe.local.lang = frappe.db.get_default("lang")
|
|
|
|
all_apps = frappe.get_installed_apps()
|
|
|
|
for app in all_apps:
|
|
|
|
locals()[app] = __import__(app)
|
|
|
|
print("Apps in this namespace:\n{}".format(", ".join(all_apps)))
|
|
|
|
IPython.embed(display_banner="", header="")
|
|
|
|
|
2020-04-28 20:15:59 +00:00
|
|
|
|
2020-03-20 15:26:23 +00:00
|
|
|
def main():
|
|
|
|
site = sys.argv[-1]
|
|
|
|
console(site)
|
2020-06-29 17:58:10 +00:00
|
|
|
if frappe.redis_server:
|
|
|
|
frappe.redis_server.connection_pool.disconnect()
|
2020-04-28 20:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|