Example #1
0
def get_site_status(verbose=False):
    import frappe
    import frappe.utils
    from frappe.utils.user import get_system_managers
    from frappe.core.doctype.user.user import get_total_users, get_active_users, \
     get_website_users, get_active_website_users

    import json
    frappe.connect()
    ret = {
        'last_backup_on': frappe.local.conf.last_backup_on,
        'active_users': get_active_users(),
        'total_users': get_total_users(),
        'active_website_users': get_active_website_users(),
        'website_users': get_website_users(),
        'system_managers': "\n".join(get_system_managers()),
        'default_company': frappe.db.get_default("company"),
        'disk_usage': frappe.utils.get_disk_usage(),
        'working_directory': frappe.local.site_path
    }

    # country, timezone, industry
    for key in ["country", "time_zone", "industry"]:
        ret[key] = frappe.db.get_default(key)

    # basic usage/progress analytics
    for doctype in ("Company", "Customer", "Item", "Quotation",
                    "Sales Invoice", "Journal Voucher", "Stock Ledger Entry"):
        key = doctype.lower().replace(" ", "_") + "_exists"
        ret[key] = 1 if frappe.db.count(doctype) else 0

    frappe.destroy()

    if verbose:
        print json.dumps(ret, indent=1, sort_keys=True)

    return ret
Example #2
0
def get_site_status(verbose=False):
	import frappe
	import frappe.utils
	from frappe.utils.user import get_system_managers
	from frappe.core.doctype.user.user import get_total_users, get_active_users, \
		get_website_users, get_active_website_users

	import json
	frappe.connect()
	ret = {
		'last_backup_on': frappe.local.conf.last_backup_on,
		'active_users': get_active_users(),
		'total_users': get_total_users(),
		'active_website_users': get_active_website_users(),
		'website_users': get_website_users(),
		'system_managers': "\n".join(get_system_managers()),
		'default_company': frappe.db.get_default("company"),
		'disk_usage': frappe.utils.get_disk_usage(),
		'working_directory': frappe.local.site_path
	}

	# country, timezone, industry
	for key in ["country", "time_zone", "industry"]:
		ret[key] = frappe.db.get_default(key)

	# basic usage/progress analytics
	for doctype in ("Company", "Customer", "Item", "Quotation", "Sales Invoice",
		"Journal Voucher", "Stock Ledger Entry"):
			key = doctype.lower().replace(" ", "_") + "_exists"
			ret[key] = 1 if frappe.db.count(doctype) else 0

	frappe.destroy()

	if verbose:
		print json.dumps(ret, indent=1, sort_keys=True)

	return ret