def change_excel_path(path): if (os.path.exists(os.path.join(path, "excel_files")) == False): os.mkdir(os.path.join(path, "excel_files")) paths["excelPath"] = os.path.join(path, "excel_files") utility.saveFileJSON( os.path.join(os.path.realpath(''), "configuration\\pathConfiguration.json"), paths) return True else: return False
def add_gateway_id(string): path = os.path.join(os.path.realpath(''), "configuration\\gatewayIdConfiguration.json") list_gateway_id = utility.readFileJSON(path) if (string not in list_gateway_id and string != ''): list_gateway_id.append(string) utility.saveFileJSON(path, list_gateway_id) return True else: return False
def add_environment_prefix(string): path = os.path.join(os.path.realpath(''), "configuration\\environmentPrefixConfiguration.json") list_environment_prefix = utility.readFileJSON(path) if (string not in list_environment_prefix and string != ''): list_environment_prefix.append(string) utility.saveFileJSON(path, list_environment_prefix) return True else: return False
def count_measures_template(file_name): list_measures = JaSONx.createListModel(file_name) diz_templates = utility.readFileJSON( os.path.realpath(''), "\\configuration\\meterMeasuresConfiguration.json") if (file_name not in diz_templates): diz_templates[file_name] = { "measuressMax": len(list_measures), "measuresSelected": len(list_measures) } utility.saveFileJSON( os.path.realpath('') + "\\configuration\\", "meterMeasuresConfiguration.json", diz_templates)
def createJSON(nameMeter, folder, template): file = utility.readFileJSON(templatesPath, template) file["parameters"]["serial_number"] = serial_number file["parameters"]["model"] = template[:template.find(".")] file["parameters"]["user_name"] = user_name file["parameters"]["password"] = password key = file["parameters"]["file_name_filter"] key["match_group_value"] = name_file_hierarchy.split("_")[1]+"_"+match_group_value file["parameters"]["meter_name"] = nameMeter file["parameters"]["maker"] = nameMeter for measureMeter in file["parameters"]["filter_tag"]: if(measureMeter["tag"]!="CommunicationCode"): measureMeter["tag"] = measureMeter["tag"].replace(measureMeter["tag"][:measureMeter["tag"].find(".")], nameMeter) utility.saveFileJSON(jsonPath+folder+"\\", nameMeter+".json", file)
def reset_path(): path = os.path.realpath('') if (os.path.exists(path + "\\json_files") == False): os.mkdir(path + "\\json_files") if (os.path.exists(path + "\\hierarchy") == False): os.mkdir(path + "\\hierarchy") if (os.path.exists(path + "\\excel_files") == False): os.mkdir(path + "\\excel_files") paths["jsonPath"] = path + "\\json_files\\" paths["hierarchyPath"] = path + "\\hierarchy\\" paths["excelPath"] = path + "\\excel_files\\" utility.saveFileJSON(path, "\\configuration\\pathConfiguration.json", paths)
def reset_path(): path = os.path.realpath('') if (os.path.exists(os.path.join(path, "json_files")) == False): os.mkdir(os.path.join(path, "json_files")) if (os.path.exists(os.path.join(path, "hierarchy")) == False): os.mkdir(os.path.join(path, "hierarchy")) if (os.path.exists(os.path.join(path, "excel_files")) == False): os.mkdir(os.path.join(path, "excel_files")) paths["jsonPath"] = os.path.join(path, "json_files") paths["hierarchyPath"] = os.path.join(path, "hierarchy") paths["excelPath"] = os.path.join(path, "excel_files") utility.saveFileJSON( os.path.join(path, "configuration\\pathConfiguration.json"), paths)
def createJSON(nameMeter, folder, template): file = utility.readFileJSON(os.path.join(templatesPath, template)) file["gateway_id"] = gateway_id file["parameters"]["environment_prefix"] = environment_prefix file["parameters"]["serial_number"] = serial_number file["parameters"]["model"] = template[:template.find(".")] file["parameters"]["user_name"] = user_name file["parameters"]["password"] = password key = file["parameters"]["file_name_filter"] key["match_group_value"] = name_file_hierarchy.split( "_")[1] + "_" + match_group_value file["parameters"]["meter_name"] = nameMeter file["parameters"]["maker"] = nameMeter for measureMeter in file["parameters"]["filter_tag"]: if (measureMeter["tag"] != "CommunicationCode"): measureMeter["tag"] = measureMeter["tag"].replace( measureMeter["tag"][:measureMeter["tag"].find(".")], nameMeter) utility.saveFileJSON(os.path.join(jsonPath, folder, nameMeter), file)
def change_excel_path(path): if (os.path.exists(path + "\\excel_files") == False): os.mkdir(path + "\\excel_files") paths["excelPath"] = path + "\\excel_files" utility.saveFileJSON(os.path.realpath(''), "\\configuration\\pathConfiguration.json", paths)
def change_hierarchy_path(path): if (os.path.exists(path + "\\hierarchy") == False): os.mkdir(path + "\\hierarchy") paths["hierarchyPath"] = path + "\\hierarchy" utility.saveFileJSON(os.path.realpath(''), "\\configuration\\pathConfiguration.json", paths)