def __init__(self): if SessionManager.session is None: if os.path.isfile(SESSION_FILE): try: SessionManager.session = load_json_file(SESSION_FILE) except: pass
def slot_upload(self): skeleton_list = self.get_selected_local_skeletons() for skeleton_name in skeleton_list: filename = self.local_skeleton_dir +os.sep + skeleton_name + ".json" data = load_json_file(filename) skeleton_name = data["name"] skeleton = json.dumps(data["skeleton"]) skeleton_model = json.dumps(data["model"]) if skeleton_name in self.db_skeletons: replace_skeleton_in_remote_db(self.db_url, skeleton_name, skeleton, skeleton_model, self.session) else: create_new_skeleton_in_db(self.db_url, skeleton_name, skeleton, skeleton_model, self.session) self.close()
def main(): config = load_json_file(CONFIG_FILE) parser = argparse.ArgumentParser(description='Start to server.') parser.add_argument('model_path', nargs='?', default=None, help='Path to model file or server url') parser.add_argument('port', nargs='?', default=None, help='Port') args = parser.parse_args() if args.model_path is not None: print("set model path to", args.model_path) config["model_path"] = args.model_path if args.port is not None: print("set port to", args.port) config["port"] = int(args.port) start_server_processes(config)
def load_local_skeleton_model(local_skeleton_dir, name): filename = local_skeleton_dir + os.sep + name + ".json" data = load_json_file(filename) return data["model"]
def replace_skeleton_model(self, filename): data = load_json_file(filename) model = data # ["skeleton_model"] self.set_skeleton_model(model)