def create_template(self): master_list_trend_id = utility.read_json_file( join(realpath(''), "configuration", "measures_config.json")) list_measures_for_template = self.create_list_measures() list_trend_id_not_found = [] self.dict_meters_not_found = {} for list_measures in list_measures_for_template: control = True new_template = utility.read_json_file( join(realpath(''), "configuration", "empty_template.json")) for measure in list_measures: if (measure in master_list_trend_id): new_template['parameters']['filter_tag'].append({ "id": master_list_trend_id[measure]['TrendID'], "period": 900, "tag": "resource." + measure }) else: list_trend_id_not_found.append(measure) control = False break if (control == True): uuid_string = str(uuid.uuid1()) utility.save_json_file( join(self.json_templates_path, "custom_template_" + uuid_string + ".json"), new_template) utility.refresh_template_configuration() return list_trend_id_not_found
def create_json(self): try: if (self.hierarchy_name not in listdir(join(self.json_files_path))): mkdir(join(self.json_files_path, self.hierarchy_name)) for meter_name, template in self.dict_meter_template.items(): if (template != "Not Found"): file_template = utility.read_json_file( join(self.json_templates_path, template)) file_template["gateway_id"] = self.gateway_id file_template["parameters"][ "environment_prefix"] = self.environment_prefix file_template["parameters"][ "serial_number"] = self.serial_number file_template["parameters"]["model"] = template[:template. find(".")] file_template["parameters"]["user_name"] = self.username file_template["parameters"]["password"] = self.password key = file_template["parameters"]["file_name_filter"] key["match_group_value"] = self.match_group_value file_template["parameters"]["meter_name"] = meter_name file_template["parameters"]["maker"] = meter_name for measure_meter in file_template["parameters"][ "filter_tag"]: if (measure_meter["tag"] != "CommunicationCode"): measure_meter["tag"] = measure_meter[ "tag"].replace( measure_meter["tag"] [:measure_meter["tag"].find(".")], meter_name) utility.save_json_file( join(self.json_files_path, self.hierarchy_name, meter_name + ".json"), file_template) except Exception as e: logging.error(e, exc_info=True)
def save(self, name='', directory=CONTROLLER_FOLDER, screenshot=True, **info): """ [CM]- SAVE() Saving out Controller geometry and its relevant info :param name:(string) File name :param directory:(string) default path to {$MAYA_USER_DIR}/{$CONTROLLER_FOLDER} :param screenshot (Boolean) if saving the screenshot to dist :param info: (Dict) extra properties to burn to meta data :return: """ # construct the file path for geo and json geo_path = util.join_file_dir(directory, name, 'ma') info_path = util.join_file_dir(directory, name, 'json') # create the directory folder to save util.create_dir(directory) # save geometry(prompt window appear if no selection) util.save_maya_file(geo_path) # save screenshot if screenshot: info['screenshot'] = util.save_screenshot(name, directory) # store Meta-data block to CM's dictionary(memory) info['name'] = name info['path'] = geo_path # append other information down here self[name] = info # [LAST STEP] save out info-block to json util.save_json_file(info, info_path)
def change_logs_file_path(path_file): if (exists(join(path_file, "logs")) == False): mkdir(join(path_file, "logs")) dict_configuration_path["logs_path"] = join(path_file, "logs") utility.save_json_file( join(realpath(''), "configuration", "path_config.json"), dict_configuration_path) return True
def change_email(string): try: path_file = join(realpath(''), "configuration", "email_config.json") file_config = utility.read_json_file(path_file) file_config["send_to"] = string utility.save_json_file(path_file, file_config) return True except: return False
def reset_path(): path_file = realpath('') if (exists(join(path_file, "json_files")) == False): mkdir(join(path_file, "json_files")) if (exists(join(path_file, "hierarchy")) == False): mkdir(join(path_file, "hierarchy")) if (exists(join(path_file, "excel_files")) == False): mkdir(join(path_file, "excel_files")) if (exists(join(path_file, "excel_templates")) == False): mkdir(join(path_file, "excel_templates")) if (exists(join(path_file, "json_templates")) == False): mkdir(join(path_file, "json_templates")) if (exists(join(path_file, "excel_final")) == False): mkdir(join(path_file, "excel_final")) if (exists(join(path_file, "logs")) == False): mkdir(join(path_file, "logs")) if (exists(join(path_file, "post_files")) == False): mkdir(join(path_file, "post_files")) dict_configuration_path["json_files_path"] = join(path_file, "json_files") dict_configuration_path["hierarchy_path"] = join(path_file, "hierarchy") dict_configuration_path["excel_files_path"] = join(path_file, "excel_files") dict_configuration_path["excel_templates_path"] = join( path_file, "excel_templates") dict_configuration_path["json_templates_path"] = join( path_file, "json_templates") dict_configuration_path["excel_final_path"] = join(path_file, "excel_final") dict_configuration_path["logs_path"] = join(path_file, "logs") dict_configuration_path["post_files_path"] = join(path_file, "post_files") utility.save_json_file( join(path_file, "configuration", "path_config.json"), dict_configuration_path)
def change_measures_set_function(self): self.message_box = QtWidgets.QMessageBox() button_reply = self.message_box.question( self, 'JasonX', "Save changes?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) if button_reply == QtWidgets.QMessageBox.Yes: for check_box in self.list_check: self.dict_measures_id[ check_box.text()]["active"] = check_box.isChecked() response = save_json_file( join(realpath(''), "configuration", "trendIdConfiguration.json"), self.dict_measures_id) if (response == True): self.message_box.about(self, "JasonX", "Measures set saved successfully!") self.close()