Merge pull request #1390 from pdvyas/bench-admin
[minor] Bench admin changes
This commit is contained in:
commit
38c877b28b
4 changed files with 26 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ redis_server = None
|
|||
def handler(f):
|
||||
cmd = f.__module__ + '.' + f.__name__
|
||||
|
||||
def run(args, set_in_response=True):
|
||||
def run(args, set_in_response=True, hijack_std=False):
|
||||
from frappe.tasks import run_async_task
|
||||
from frappe.handler import execute_cmd
|
||||
if frappe.conf.disable_async:
|
||||
|
|
@ -28,7 +28,7 @@ def handler(f):
|
|||
args = frappe._dict(args)
|
||||
task = run_async_task.delay(site=frappe.local.site,
|
||||
user=(frappe.session and frappe.session.user) or 'Administrator', cmd=cmd,
|
||||
form_dict=args)
|
||||
form_dict=args, hijack_std=hijack_std)
|
||||
if set_in_response:
|
||||
frappe.local.response['task_id'] = task.id
|
||||
return task.id
|
||||
|
|
@ -159,7 +159,7 @@ def put_log(line_no, line, task_id=None):
|
|||
"lines": {line_no: line}
|
||||
},
|
||||
"task_id": task_id
|
||||
}, room=task_progress_room)
|
||||
}, room=task_progress_room, now=True)
|
||||
r.hset(task_log_key, line_no, line)
|
||||
r.expire(task_log_key, 3600)
|
||||
|
||||
|
|
|
|||
|
|
@ -126,9 +126,8 @@ def restore(context, sql_file_path, mariadb_root_username=None, mariadb_root_pas
|
|||
|
||||
site = get_single_site(context)
|
||||
frappe.init(site=site)
|
||||
if not db_name:
|
||||
db_name = frappe.conf.db_name
|
||||
_new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=context.verbose, install_apps=install_app, source_sql=sql_file_path, force=context.force)
|
||||
db_name = db_name or frappe.conf.db_name or hashlib.sha1(site).hexdigest()[:10]
|
||||
_new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=context.verbose, install_apps=install_app, source_sql=sql_file_path, force=context.force)
|
||||
|
||||
@click.command('reinstall')
|
||||
@pass_context
|
||||
|
|
@ -447,7 +446,6 @@ def execute(context, method, args=None, kwargs=None):
|
|||
try:
|
||||
frappe.init(site=site)
|
||||
frappe.connect()
|
||||
print frappe.local.site
|
||||
|
||||
if args:
|
||||
args = eval(args)
|
||||
|
|
@ -466,7 +464,7 @@ def execute(context, method, args=None, kwargs=None):
|
|||
finally:
|
||||
frappe.destroy()
|
||||
if ret:
|
||||
print ret
|
||||
print json.dumps(ret)
|
||||
|
||||
@click.command('celery')
|
||||
@click.argument('args')
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ class BackupGenerator:
|
|||
for item in self.__dict__.copy().items())
|
||||
cmd_string = """mysqldump --single-transaction --quick --lock-tables=false -u %(user)s -p%(password)s %(db_name)s -h %(db_host)s | gzip -c > %(backup_path_db)s""" % args
|
||||
err, out = frappe.utils.execute_in_shell(cmd_string)
|
||||
print 'Database backed up', os.path.abspath(self.backup_path_db)
|
||||
|
||||
def send_email(self):
|
||||
"""
|
||||
|
|
@ -193,6 +192,13 @@ def get_backup_path():
|
|||
return backup_path
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def backup(with_files=False, backup_path_db=None, backup_path_files=None, quiet=False):
|
||||
"Backup"
|
||||
odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=True)
|
||||
return {
|
||||
"backup_path_db": odb.backup_path_db,
|
||||
"backup_path_files": odb.backup_path_files
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -292,3 +292,16 @@ def is_website_user():
|
|||
|
||||
def is_system_user(username):
|
||||
return frappe.db.get_value("User", {"name": username, "enabled": 1, "user_type": "System User"})
|
||||
|
||||
def get_users():
|
||||
from frappe.core.doctype.user.user import get_system_users
|
||||
users = []
|
||||
system_managers = frappe.utils.user.get_system_managers(only_name=True)
|
||||
for user in get_system_users():
|
||||
users.append({
|
||||
"full_name": frappe.utils.user.get_user_fullname(user),
|
||||
"email": user,
|
||||
"is_system_manager": 1 if (user in system_managers) else 0
|
||||
})
|
||||
|
||||
return users
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue