def install_fixtures(): print "Importing install fixtures..." for basepath, folders, files in os.walk( os.path.join("app", "startup", "install_fixtures")): for f in files: f = cstr(f) if f.endswith(".json"): print "Importing " + f with open(os.path.join(basepath, f), "r") as infile: webnotes.bean(json.loads(infile.read())).insert_or_update() webnotes.conn.commit() if f.endswith(".csv"): from core.page.data_import_tool.data_import_tool import import_file_by_path import_file_by_path(os.path.join(basepath, f), ignore_links=True, overwrite=True) webnotes.conn.commit() if os.path.exists( os.path.join("app", "startup", "install_fixtures", "files")): if not os.path.exists(os.path.join("public", "files")): os.makedirs(os.path.join("public", "files")) os.system("cp -r %s %s" % (os.path.join("app", "startup", "install_fixtures", "files", "*"), os.path.join("public", "files")))
def install_fixtures(): print "Importing install fixtures..." for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")): for f in files: f = cstr(f) if f.endswith(".json"): print "Importing " + f with open(os.path.join(basepath, f), "r") as infile: webnotes.bean(json.loads(infile.read())).insert_or_update() webnotes.conn.commit() if f.endswith(".csv"): from core.page.data_import_tool.data_import_tool import import_file_by_path import_file_by_path(os.path.join(basepath, f), ignore_links = True, overwrite=True) webnotes.conn.commit() if os.path.exists(os.path.join("app", "startup", "install_fixtures", "files")): if not os.path.exists(os.path.join("public", "files")): os.makedirs(os.path.join("public", "files")) os.system("cp -r %s %s" % (os.path.join("app", "startup", "install_fixtures", "files", "*"), os.path.join("public", "files")))
import json if os.path.isdir(options.import_doclist): docs = [os.path.join(options.import_doclist, f) \ for f in os.listdir(options.import_doclist)] else: docs = [options.import_doclist] for f in docs: if f.endswith(".json"): with open(f, "r") as infile: b = webnotes.bean(json.loads(infile.read())).insert_or_update() print "Imported: " + b.doc.doctype + " / " + b.doc.name webnotes.conn.commit() if f.endswith(".csv"): from core.page.data_import_tool.data_import_tool import import_file_by_path import_file_by_path(f, ignore_links=True) webnotes.conn.commit() 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 elif options.make_conf: if os.path.exists("conf.py"): os.system("mv conf.py conf.py.bak")