def gen_module(file, recreate): model_def = create_model_def(file) prefix = "./output/" module_name = model_def.name module_path = prefix + module_name if recreate and os.path.isdir(module_path): shutil.rmtree(module_path) if os.path.isdir(module_path): print("module folder", module_path, "already exists.") return io_utils.create_dir(module_path) db_path = module_path + "/database" seed_path = module_path + "/database/data" io_utils.create_dir(seed_path) copyfile("./templates/api.py", module_path + "/api.py") copyfile("./templates/utils.py", module_path + "/utils.py") ## copy seed files for path in io_utils.list_files("./seeds/" + module_name): copyfile(path, seed_path + "/" + os.path.basename(path)) write_db_settings(model_def, db_path + "/base.py") for m in model_def.models: write_model(model_def, m) print("all done.")
def get_form_list(): oc.import_package('org.apache.ofbiz.base.component.ComponentConfig') allComponents = oc.j.ComponentConfig.getAllComponents() form_list=[] for c in allComponents: # print(c.getRootLocation()) widget_dir=c.getRootLocation()+"widget" if os.path.isdir(widget_dir): files=io_utils.list_files(widget_dir) logging.info(c.getGlobalName(), len(files)) counts={'forms':0, 'screens':0, 'menus':0, 'trees':0, 'others':0} for f in files: base=os.path.basename(f) name=os.path.splitext(base)[0] if 'Form' in name: counts['forms']=counts['forms']+1 form_list.append(FormResource(c.getGlobalName(), name, f)) elif 'Screen' in name: counts['screens']=counts['screens']+1 elif 'Menu' in name: counts['menus']=counts['menus']+1 elif 'Tree' in name: counts['trees']=counts['trees']+1 elif name=='Theme': pass else: counts['others']=counts['others']+1 logging.info('** get unexpected file type %s', name) logging.debug('\t%s', counts) logging.info("total form files %d", len(form_list)) return form_list
def process(self): from sagas.ofbiz.services import OfService as s, oc, track oc.import_package('org.apache.ofbiz.base.component.ComponentConfig') allComponents = oc.j.ComponentConfig.getAllComponents() properties = {} for c in allComponents: conf_dir = c.getRootLocation() + 'config' if os.path.isdir(conf_dir): files = io_utils.list_files(conf_dir) for f in files: if f.endswith('.xml'): self.parse_resource_file(f, properties) resource = RsResource(properties=properties) return resource
def get_timestamps(self): import io_utils import os last_timestamps = {} for mod in mods: folder = f"{prefix}/{mod}/" # print(folder) # print(os.listdir(folder)) files = [(f, os.path.getmtime(f)) for f in io_utils.list_files(folder) if os.path.isfile(f)] # print(len(files)) files = sorted(files, key=lambda x: x[1], reverse=True) last_modified_file = None if len(files) == 0 else files[0][0] if last_modified_file is not None: mark = os.path.getmtime(last_modified_file) # print(last_modified_file, mark) last_timestamps[mod] = mark return last_timestamps