logging.info("Read mapping...") mapping = json.load(open(ARGS.mapping)) logging.info("Keep backup of mapping rules...") if "/" in ARGS.mapping: mapping_dir = "/".join(ARGS.mapping.split("/")) mapping_file = ARGS.mapping.split("/")[-1].split(".")[0] else: mapping_dir = "." mapping_file = ARGS.mapping.split(".")[0] save = f"{mapping_dir}/{mapping_file}-{TIMESTAMP}.json" json.dump(mapping, open(save, "w")) logging.info(f"Current mapping save in {save}") logging.info("Access couchDB database...") COUCHDB = couch_wrapper.Wrapper(ARGS.url) if not COUCHDB.couchPing(): raise Exception("Can't ping database") logging.info("Modify mapping rules...") if ARGS.subparser_name == "use_current": new_mapping = backup_to_current(mapping) elif ARGS.subparser_name == "use_backup": new_mapping = current_to_backup(mapping, ARGS.version) logging.info("Write new mapping rules...") json.dump(new_mapping, open(ARGS.mapping, "w")) logging.info(f"New mapping rules in {ARGS.mapping}") logging.info("END - Relaunch motif-broker with this new mapping rules")
def _init_wrapper(self, url: str, admin: Tuple[str,str]) -> wrapper.Wrapper: wrapperObj = wrapper.Wrapper(url, admin) if not wrapperObj.couchPing(): raise Exception(f"Can't ping {url}") return wrapperObj