From b3ac8fe6d7d24fbe489ecb3afcc6fa707662d6e3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 4 Oct 2013 21:19:01 +0530 Subject: [PATCH 1/7] [minor] [fix] wnf --- wnf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wnf.py b/wnf.py index ec1dadbf05..aaea9409b5 100755 --- a/wnf.py +++ b/wnf.py @@ -30,6 +30,7 @@ def cmd(fn): for a in fnargs: if a in kwargs: new_kwargs[a] = kwargs.get(a) + return fn(*args, **new_kwargs) return new_fn @@ -187,10 +188,10 @@ def setup_translation(parser): # install @cmd -def install(db_name, site=None, verbose=True, force=False, root_password=None): +def install(db_name, source_sql=None, site=None, verbose=True, force=False, root_password=None): from webnotes.install_lib.install import Installer inst = Installer('root', db_name=db_name, site=site, root_password=root_password) - inst.install(db_name, verbose=verbose, force=force) + inst.install(db_name, source_sql=source_sql, verbose=verbose, force=force) @cmd def reinstall(site=None, verbose=True): From 3757916024cb15a8dfb7cad4501ec31a2673897c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 4 Oct 2013 21:24:08 +0530 Subject: [PATCH 2/7] [minor] [fix] wnf --- wnf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wnf.py b/wnf.py index aaea9409b5..137159cd59 100755 --- a/wnf.py +++ b/wnf.py @@ -237,6 +237,7 @@ def latest(site=None, verbose=True): import webnotes.model.sync webnotes.connect(site=site) + try: # run patches webnotes.modules.patch_handler.log_list = [] @@ -424,6 +425,7 @@ def get_remote_and_branch(remote=None, branch=None): remote = remote or "origin" branch = branch or webnotes.conf.branch + webnotes.destroy() return remote, branch From c95f18f2ade3a08acd69e86f2ee21006aaa2da21 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Fri, 4 Oct 2013 13:54:21 +0530 Subject: [PATCH 3/7] add set_admin_password utility --- wnf.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wnf.py b/wnf.py index 137159cd59..b8cf0b8f4f 100755 --- a/wnf.py +++ b/wnf.py @@ -123,6 +123,8 @@ def setup_utilities(parser): help="Get or set domain in Website Settings") parser.add_argument("--make_conf", nargs="*", metavar=("DB-NAME", "DB-PASSWORD"), help="Create new conf.py file") + parser.add_argument("--set_admin_password", metavar='ADMIN-PASSWORD', nargs=1, + help="Set administrator password") # clear parser.add_argument("--clear_web", default=False, action="store_true", @@ -451,6 +453,15 @@ def commit(message): def checkout(branch): git(("checkout", branch)) +@cmd +def set_admin_password(admin_password, site=None): + import webnotes + webnotes.connect(site=site) + webnotes.conn.sql("""update __Auth set `password`=password(%s) + where user='Administrator'""", (admin_password,)) + webnotes.conn.commit() + webnotes.destroy() + def replace_code(start, txt1, txt2, extn, search=None, force=False): """replace all txt1 by txt2 in files with extension (extn)""" import webnotes.utils @@ -498,4 +509,4 @@ def search_replace_with_prompt(fpath, txt1, txt2, force=False): print colored('Updated', 'green') if __name__=="__main__": - main() \ No newline at end of file + main() From ebe0e7d64bb1700d901b97eb304d98e14d3d143c Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 7 Oct 2013 08:24:34 +0530 Subject: [PATCH 4/7] [minor] return backup generator obj from wnf.backup --- webnotes/utils/backups.py | 1 + wnf.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index caa43dd4f1..fa943a2e24 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -140,6 +140,7 @@ def scheduled_backup(older_than=6, ignore_files=False): from webnotes.utils import now print "backup taken -", odb.backup_path_db, "- on", now() + return odb def new_backup(older_than=6, ignore_files=False): delete_temp_backups(older_than=168) diff --git a/wnf.py b/wnf.py index b8cf0b8f4f..ae814898dc 100755 --- a/wnf.py +++ b/wnf.py @@ -293,7 +293,10 @@ def watch(): def backup(site=None, with_files=False): from webnotes.utils.backups import scheduled_backup webnotes.connect(site=site) - scheduled_backup(ignore_files=not with_files) + odb = scheduled_backup(ignore_files=not with_files) + if __name__ == "__main__": + print "backup taken -", odb.backup_path_db, "- on", now() + return odb @cmd def docs(): From 729239109e22da65858005a4501c75b2d9922c5c Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 7 Oct 2013 08:46:07 +0530 Subject: [PATCH 5/7] [minor] add move to wnf.py --- wnf.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wnf.py b/wnf.py index ae814898dc..1dba1fdeeb 100755 --- a/wnf.py +++ b/wnf.py @@ -115,6 +115,10 @@ def setup_utilities(parser): # misc parser.add_argument("--backup", default=False, action="store_true", help="Take backup of database in backup folder [--with_files]") + parser.add_argument("--move", default=False, action="store_true", + help="Move site to different directory defined by --dest_dir") + parser.add_argument("--dest_dir", nargs=1, metavar="DEST-DIR", + help="Move site to different directory") parser.add_argument("--with_files", default=False, action="store_true", help="Also take backup of files") parser.add_argument("--docs", default=False, action="store_true", @@ -298,6 +302,21 @@ def backup(site=None, with_files=False): print "backup taken -", odb.backup_path_db, "- on", now() return odb +@cmd +def move(site=None, dest_dir=None): + import os + import shutil + if not dest_dir: + raise Exception, "--dest_dir is required for --move" + dest_dir = dest_dir[0] + if not os.path.isdir(dest_dir): + raise Exception, "destination is not a directory or does not exist" + webnotes.init(site=site) + old_path = webnotes.utils.get_site_path() + new_path = os.path.join(dest_dir, site) + shutil.move(old_path, new_path) + webnotes.destroy() + @cmd def docs(): from core.doctype.documentation_tool.documentation_tool import write_static From 09a9736d81a5c43ceffc3a9b86d88903b9be0204 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 7 Oct 2013 10:52:56 +0530 Subject: [PATCH 6/7] [minor] add counting logic to wnf.move --- wnf.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wnf.py b/wnf.py index 1dba1fdeeb..8673319a4f 100755 --- a/wnf.py +++ b/wnf.py @@ -305,7 +305,6 @@ def backup(site=None, with_files=False): @cmd def move(site=None, dest_dir=None): import os - import shutil if not dest_dir: raise Exception, "--dest_dir is required for --move" dest_dir = dest_dir[0] @@ -314,7 +313,16 @@ def move(site=None, dest_dir=None): webnotes.init(site=site) old_path = webnotes.utils.get_site_path() new_path = os.path.join(dest_dir, site) - shutil.move(old_path, new_path) + + # check if site dump of same name already exists + site_dump_exists = True + count = 0 + while site_dump_exists: + final_new_path = new_path + (count and str(count) or "") + site_dump_exists = os.path.exists(final_new_path) + count = int(count or 0) + 1 + + os.rename(old_path, final_new_path) webnotes.destroy() @cmd From 08bb06fab56432caf03a2b325b66012146944540 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 7 Oct 2013 18:05:49 +0530 Subject: [PATCH 7/7] [minor] appframe module icon can have custom onclick function --- public/js/wn/ui/appframe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index 297617d959..5c1cf43819 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -71,7 +71,7 @@ wn.ui.AppFrame = Class.extend({ this.$w.find(".info-bar").toggle(false).find("ul").empty(); }, - add_module_icon: function(module, doctype) { + add_module_icon: function(module, doctype, onclick) { var module_info = wn.modules[module]; if(!module_info) { module_info = { @@ -87,7 +87,7 @@ wn.ui.AppFrame = Class.extend({ "background-color": module_info.color, }) .attr("doctype-name", doctype) - .click(function() { + .click(onclick || function() { if($(this).attr("doctype-name")) { wn.set_route("List", $(this).attr("doctype-name")) } else {