def backup(site=None, with_files=False, verbose=True, backup_path_db=None, backup_path_files=None): from webnotes.utils.backups import scheduled_backup webnotes.connect(site=site) print backup_path_db odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files) if verbose: from webnotes.utils import now print "backup taken -", odb.backup_path_db, "- on", now() return odb
def backup(site=None, with_files=False, verbose=True, backup_path_db=None, backup_path_files=None, delete_older_than=6): from webnotes.utils.backups import scheduled_backup webnotes.connect(site=site) odb = scheduled_backup(delete_older_than=delete_older_than, ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files) if verbose: from webnotes.utils import now print "database backup taken -", odb.backup_path_db, "- on", now() if with_files: print "files backup taken -", odb.backup_path_files, "- on", now() webnotes.destroy() return odb
def backup(site=None, with_files=False, verbose=True, backup_path_db=None, backup_path_files=None): from webnotes.utils.backups import scheduled_backup webnotes.connect(site=site) odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files) if verbose: from webnotes.utils import now print "database backup taken -", odb.backup_path_db, "- on", now() if with_files: print "files backup taken -", odb.backup_path_files, "- on", now() webnotes.destroy() return odb
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes.utils import bundlejs if options.no_cms: cms_make = False else: cms_make = True bundlejs.bundle(False, cms_make) return elif options.watch: from webnotes.utils import bundlejs bundlejs.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull, options.install_fresh]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir('lib') os.system('git commit -a -m "%s"' % (options.commit)) os.chdir('../app') os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: os.chdir('lib') os.system('git push %s %s' % (options.push[0], options.push[1])) os.chdir('../app') os.system('git push %s %s' % (options.push[0], options.push[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], verbose=1) elif options.install_fresh: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install_fresh, source_path="lib/conf/Framework.sql", verbose=1) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: webnotes.reload_doc(options.sync[0], "doctype", options.sync[1]) elif options.update: update_erpnext(options.update[0], options.update[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import webnotes.webutils webnotes.webutils.clear_cache() elif options.clear_cache: clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup(ignore_files=True) # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) if options.test is not None: module_name = options.test import unittest del sys.argv[1:] # is there a better way? exec('from %s import *' % module_name) in globals() unittest.main() elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate webnotes.translate.import_messages(*options.import_messages) elif options.google_translate: from webnotes.translate import google_translate google_translate(*options.google_translate) elif options.translate: from webnotes.translate import build_message_files, \ export_messages, google_translate, import_messages languages = [options.translate] if options.translate == "all": from startup import lang_list languages = lang_list print "Extracting messages..." build_message_files() for lang in languages: if lang != "en": filename = 'app/translations/' + lang + '.csv' print "For " + lang + ":" print "Compiling messages in one file..." export_messages(lang, '_lang_tmp.csv') print "Translating via Google Translate..." google_translate(lang, '_lang_tmp.csv', filename) print "Updating language files..." import_messages(lang, filename) print "Deleting temp files..." os.remove('_lang_tmp.csv')
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes.utils import bundlejs if options.no_cms: cms_make = False else: cms_make = True bundlejs.bundle(options.no_compress, cms_make) return elif options.watch: from webnotes.utils import bundlejs bundlejs.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir('lib') os.system('git commit -a -m "%s"' % (options.commit)) os.chdir('../app') os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: os.chdir('lib') os.system('git push %s %s' % (options.push[0], options.push[1])) os.chdir('../app') os.system('git push %s %s' % (options.push[0], options.push[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], \ password='******', verbose = 1) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: import webnotes.model.sync webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0) elif options.update: update_erpnext(options.update[0], options.update[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import website.utils website.utils.clear_cache() elif options.clear_cache: clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup() # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) if options.test is not None: module_name = options.test import unittest del sys.argv[1:] # is there a better way? exec ('from %s import *' % module_name) in globals() unittest.main()
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes.utils import bundlejs if options.no_cms: cms_make = False else: cms_make = True bundlejs.bundle(False, cms_make) return elif options.watch: from webnotes.utils import bundlejs bundlejs.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull, options.install_fresh]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir('lib') os.system('git commit -a -m "%s"' % (options.commit)) os.chdir('../app') os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: os.chdir('lib') os.system('git push %s %s' % (options.push[0], options.push[1])) os.chdir('../app') os.system('git push %s %s' % (options.push[0], options.push[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], verbose = 1) elif options.install_fresh: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install_fresh, source_path="lib/conf/Framework.sql", verbose = 1) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: import webnotes.model.sync webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0) elif options.update: update_erpnext(options.update[0], options.update[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import website.utils website.utils.clear_cache() elif options.clear_cache: clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup() # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) if options.test is not None: module_name = options.test import unittest del sys.argv[1:] # is there a better way? exec ('from %s import *' % module_name) in globals() unittest.main() elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate webnotes.translate.import_messages(*options.import_messages) elif options.google_translate: from webnotes.translate import google_translate google_translate(*options.google_translate) elif options.translate: from webnotes.translate import build_message_files, \ export_messages, google_translate, import_messages languages = [options.translate] if options.translate=="all": from startup import lang_list languages = lang_list print "Extracting messages..." build_message_files() for lang in languages: if lang != "en": filename = 'app/translations/'+lang+'.csv' print "For " + lang + ":" print "Compiling messages in one file..." export_messages(lang, '_lang_tmp.csv') print "Translating via Google Translate..." google_translate(lang, '_lang_tmp.csv', filename) print "Updating language files..." import_messages(lang, filename) print "Deleting temp files..." os.remove('_lang_tmp.csv')
webnotes.webutils.clear_cache() elif options.clear_cache: clear_cache() elif options.clear_defaults: import webnotes.defaults webnotes.defaults.clear_cache() webnotes.clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup(ignore_files = True) # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes import build if options.no_cms: cms_make = False else: cms_make = True build.bundle(False, cms_make) return elif options.watch: from webnotes import build build.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler webnotes.print_messages = True # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull, options.install_fresh]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir('lib') os.system('git commit -a -m "%s"' % (options.commit)) os.chdir('../app') os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: if not args: args = ["origin", conf.branch] os.chdir('lib') os.system('git push %s %s' % (args[0], args[1])) os.chdir('../app') os.system('git push %s %s' % (args[0], args[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], verbose = 1) elif options.install_fresh: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install_fresh, verbose = 1) elif options.make_demo: import utilities.make_demo utilities.make_demo.make() elif options.make_demo_fresh: import utilities.make_demo utilities.make_demo.make(True) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: webnotes.reload_doc(options.sync[0], "doctype", options.sync[1]) elif options.update: if not args: args = ["origin", conf.branch] update_erpnext(args[0], args[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import webnotes.webutils webnotes.webutils.clear_cache() elif options.clear_cache: clear_cache() elif options.clear_defaults: import webnotes.defaults webnotes.defaults.clear_cache() webnotes.clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup(ignore_files = True) # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate webnotes.translate.import_messages(*options.import_messages) elif options.google_translate: from webnotes.translate import google_translate google_translate(*options.google_translate) elif options.translate: from webnotes.translate import translate translate(options.translate) elif options.docs: from core.doctype.documentation_tool.documentation_tool import write_static write_static() elif options.reset_perms: for d in webnotes.conn.sql_list("""select name from `tabDocType` where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""): try: webnotes.clear_cache(doctype=d) webnotes.reset_perms(d) except: pass
def run(): sys.path.append(".") sys.path.append("lib") sys.path.append("app") (options, args) = setup_options() # build if options.build: from webnotes.utils import bundlejs if options.no_cms: cms_make = False else: cms_make = True bundlejs.bundle(False, cms_make) return elif options.watch: from webnotes.utils import bundlejs bundlejs.watch(True) return # code replace elif options.replace: print options.replace replace_code(".", options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir("lib") os.system("git status") os.chdir("../app") os.system("git status") return elif options.git: os.chdir("lib") os.system("git %s" % options.git) os.chdir("../app") os.system("git %s" % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir("lib") os.system('git commit -a -m "%s"' % (options.commit)) os.chdir("../app") os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: os.chdir("lib") os.system("git push %s %s" % (options.push[0], options.push[1])) os.chdir("../app") os.system("git push %s %s" % (options.push[0], options.push[1])) elif options.checkout: os.chdir("lib") os.system("git checkout %s" % options.checkout) os.chdir("../app") os.system("git checkout %s" % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(patchmodule=patch, force=options.force) print "\n".join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc( {"module": options.reload_doc[0], "dt": options.reload_doc[1], "dn": options.reload_doc[2]} ) print "\n".join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer("root") inst.import_from_db(options.install[0], source_path=options.install[1], password="******", verbose=1) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger("execute_" + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: import webnotes.model.sync webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0) elif options.update: update_erpnext(options.update[0], options.update[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value("Website Settings", None, "subdomain", options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import website.utils website.utils.clear_cache() elif options.clear_cache: clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup() # print messages if webnotes.message_log: print "\n".join(webnotes.message_log) if options.test is not None: module_name = options.test import unittest del sys.argv[1:] # is there a better way? exec ("from %s import *" % module_name) in globals() unittest.main() elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate webnotes.translate.import_messages(*options.import_messages) elif options.google_translate: from webnotes.translate import google_translate google_translate(*options.google_translate) elif options.translate: from webnotes.translate import build_message_files, export_messages, google_translate, import_messages print "Extracting messages..." build_message_files() print "Compiling messages in one file..." export_messages(options.translate, "_lang_tmp.csv") print "Translating via Google Translate..." google_translate(options.translate, "_lang_tmp.csv", "_lang_tmp1.csv") print "Updating language files..." import_messages(options.translate, "_lang_tmp1.csv") print "Deleting temp files..." os.remove("_lang_tmp.csv") os.remove("_lang_tmp1.csv")
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes.utils import bundlejs if options.no_cms: cms_make = False else: cms_make = True bundlejs.bundle(options.no_compress, cms_make) return elif options.watch: from webnotes.utils import bundlejs bundlejs.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.push: os.chdir('lib') os.system('git commit -a -m "%s"' % options.push[2]) os.system('git push %s %s' % (options.push[0], options.push[1])) os.chdir('../app') os.system('git commit -a -m "%s"' % options.push[2]) os.system('git push %s %s' % (options.push[0], options.push[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], \ password='******', verbose = 1) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: import webnotes.model.sync webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0) elif options.update: update_erpnext(options.update[0], options.update[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.build_web_cache: # build wn-web.js and wn-web.css import webnotes.cms.make webnotes.cms.make.make() import website.web_cache website.web_cache.refresh_cache(['Blog']) elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup() # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) if options.test is not None: module_name = options.test import unittest del sys.argv[1:] # is there a better way? exec('from %s import *' % module_name) in globals() unittest.main()
def run(): sys.path.append('.') sys.path.append('lib') sys.path.append('app') (options, args) = setup_options() # build if options.build: from webnotes import build if options.no_cms: cms_make = False else: cms_make = True build.bundle(False, cms_make) return elif options.watch: from webnotes import build build.watch(True) return # code replace elif options.replace: print options.replace replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force) return # git elif options.status: os.chdir('lib') os.system('git status') os.chdir('../app') os.system('git status') return elif options.git: os.chdir('lib') os.system('git %s' % options.git) os.chdir('../app') os.system('git %s' % options.git) return import webnotes import conf from webnotes.db import Database import webnotes.modules.patch_handler webnotes.print_messages = True # connect if options.db_name is not None: if options.password: webnotes.connect(options.db_name, options.password) else: webnotes.connect(options.db_name) elif not any([options.install, options.pull, options.install_fresh]): webnotes.connect(conf.db_name) if options.pull: pull(options.pull[0], options.pull[1], build=True) elif options.commit: os.chdir('lib') os.system('git commit -a -m "%s"' % (options.commit)) os.chdir('../app') os.system('git commit -a -m "%s"' % (options.commit)) elif options.push: if not args: args = ["origin", conf.branch] os.chdir('lib') os.system('git push %s %s' % (args[0], args[1])) os.chdir('../app') os.system('git push %s %s' % (args[0], args[1])) elif options.checkout: os.chdir('lib') os.system('git checkout %s' % options.checkout) os.chdir('../app') os.system('git checkout %s' % options.checkout) # patch elif options.patch_list: # clear log webnotes.modules.patch_handler.log_list = [] # run individual patches for patch in options.patch_list: webnotes.modules.patch_handler.run_single(\ patchmodule = patch, force = options.force) print '\n'.join(webnotes.modules.patch_handler.log_list) # reload elif options.reload_doc: webnotes.modules.patch_handler.reload_doc(\ {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) elif options.export_doc: from webnotes.modules import export_doc export_doc(options.export_doc[0], options.export_doc[1]) # run all pending elif options.run_latest: apply_latest_patches() elif options.install: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install[0], source_path=options.install[1], verbose=1) elif options.install_fresh: from webnotes.install_lib.install import Installer inst = Installer('root') inst.import_from_db(options.install_fresh, verbose=1) elif options.make_demo: import utilities.make_demo utilities.make_demo.make() elif options.make_demo_fresh: import utilities.make_demo utilities.make_demo.make(True) elif options.diff_ref_file is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_file() elif options.diff_ref_db is not None: import webnotes.modules.diff webnotes.modules.diff.diff_ref_db() elif options.run_scheduler: import webnotes.utils.scheduler print webnotes.utils.scheduler.execute() elif options.run_scheduler_event is not None: import webnotes.utils.scheduler print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event) elif options.sync_all is not None: sync_all(options.force or 0) elif options.sync is not None: webnotes.reload_doc(options.sync[0], "doctype", options.sync[1]) elif options.update: if not args: args = ["origin", conf.branch] update_erpnext(args[0], args[1]) elif options.patch_sync_build: patch_sync_build() elif options.patch_sync: patch_sync() elif options.cleanup_data: from utilities import cleanup_data cleanup_data.run() elif options.domain: webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain) webnotes.conn.commit() print "Domain set to", options.domain elif options.clear_web: # build wn-web.js and wn-web.css from website.helpers.make_web_include_files import make make() import webnotes.webutils webnotes.webutils.clear_cache() elif options.clear_cache: clear_cache() elif options.clear_defaults: import webnotes.defaults webnotes.defaults.clear_cache() webnotes.clear_cache() elif options.append_future_import: append_future_import() elif options.backup: from webnotes.utils.backups import scheduled_backup scheduled_backup(ignore_files=True) # print messages if webnotes.message_log: print '\n'.join(webnotes.message_log) elif options.build_message_files: import webnotes.translate webnotes.translate.build_message_files() elif options.export_messages: import webnotes.translate webnotes.translate.export_messages(*options.export_messages) elif options.import_messages: import webnotes.translate webnotes.translate.import_messages(*options.import_messages) elif options.google_translate: from webnotes.translate import google_translate google_translate(*options.google_translate) elif options.translate: from webnotes.translate import translate translate(options.translate) elif options.docs: from core.doctype.documentation_tool.documentation_tool import write_static write_static() elif options.reset_perms: for d in webnotes.conn.sql_list("""select name from `tabDocType` where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""): try: webnotes.clear_cache(doctype=d) webnotes.reset_perms(d) except: pass