Beispiel #1
0
 def createJson(self):
     if (self.name_hierarchy
             not in os.listdir(os.path.join(self.json_files_path))):
         os.mkdir(os.path.join(self.json_files_path, self.name_hierarchy))
     for meter_name, template in self.dict_meter_template.items():
         if (template != "Not Found"):
             file = utility.readJsonFile(
                 os.path.join(self.json_templates_path, template))
             file["gateway_id"] = self.gateway_id
             file["parameters"][
                 "environment_prefix"] = self.environment_prefix
             file["parameters"]["serial_number"] = self.serial_number
             file["parameters"]["model"] = template[:template.find(".")]
             file["parameters"]["user_name"] = self.username
             file["parameters"]["password"] = self.password
             key = file["parameters"]["file_name_filter"]
             key["match_group_value"] = self.match_group_value
             file["parameters"]["meter_name"] = meter_name
             file["parameters"]["maker"] = meter_name
             for measure_meter in file["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.saveJsonFile(
                 os.path.join(self.json_files_path, self.name_hierarchy,
                              meter_name + ".json"), file)
Beispiel #2
0
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"))

    if (os.path.exists(os.path.join(path, "json_templates")) == False):
        os.mkdir(os.path.join(path, "json_templates"))

    if (os.path.exists(os.path.join(path, "excel_final")) == False):
        os.mkdir(os.path.join(path, "excel_final"))

    dict_configuration_path["json_files_path"] = os.path.join(
        path, "json_files")
    dict_configuration_path["hierarchy_path"] = os.path.join(path, "hierarchy")
    dict_configuration_path["excel_files_path"] = os.path.join(
        path, "excel_files")
    dict_configuration_path["json_templates_path"] = os.path.join(
        path, "json_templates")
    dict_configuration_path["excel_final_path"] = os.path.join(
        path, "excel_final")
    utility.saveJsonFile(
        os.path.join(path, "configuration", "pathConfiguration.json"),
        dict_configuration_path)
Beispiel #3
0
def change_hierarchy_path(path):
    if (os.path.exists(os.path.join(path, "hierarchy")) == False):
        os.mkdir(os.path.join(path, "hierarchy"))
    dict_configuration_path["hierarchy_path"] = os.path.join(path, "hierarchy")
    utility.saveJsonFile(
        os.path.join(os.path.realpath(''), "configuration",
                     "pathConfiguration.json"), dict_configuration_path)
    return True
Beispiel #4
0
def add_gateway_id(string):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "gatewayIdConfiguration.json")
    list_gateway_id = utility.readJsonFile(path)
    if (string not in list_gateway_id and string != ''):
        list_gateway_id.append(string)
        utility.saveJsonFile(path, list_gateway_id)
        return True
    else:
        return False
Beispiel #5
0
def add_environment_prefix(string):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "environmentPrefixConfiguration.json")
    list_environment_prefix = utility.readJsonFile(path)
    if (string not in list_environment_prefix and string != ''):
        list_environment_prefix.append(string)
        utility.saveJsonFile(path, list_environment_prefix)
        return True
    else:
        return False
Beispiel #6
0
def add_trend_id(trend_id, channel, multipler):
    path = os.path.join(os.path.realpath(''), "configuration",
                        "trendIdConfiguration.json")
    dict_trend_id = utility.readJsonFile(path)
    if (trend_id not in dict_trend_id and trend_id != ''):
        dict_trend_id[trend_id] = {
            "channel": channel,
            "multipler": multipler,
            "active": False
        }
        utility.saveJsonFile(path, dict_trend_id)
        return True
    else:
        return False
 def on_button_clicked(self, state):
     msgBox = QtWidgets.QMessageBox()
     buttonReply = msgBox.question(
         self, 'JaSONx', "Save changes?",
         QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
         QtWidgets.QMessageBox.No)
     if buttonReply == QtWidgets.QMessageBox.Yes:
         for check_box in self.lista:
             self.dict_measures_id[
                 check_box.text()]["active"] = check_box.isChecked()
         response = utility.saveJsonFile(
             os.path.join(os.path.realpath(''), "configuration",
                          "trendIdConfiguration.json"),
             self.dict_measures_id)
         if (response == True):
             msgBox.about(self, "JaSONx",
                          "Measures set saved successfully!")
     self.close()
Beispiel #8
0
def control_paths():
    path = os.path.realpath('')
    if (os.path.exists(json_files_path) == False):
        if (os.path.exists(os.path.join(path, "json_files")) == False):
            os.mkdir(os.path.join(path, "json_files"))
            dict_configuration_path["json_files_path"] = os.path.join(
                path, "json_files_path")
        else:
            dict_configuration_path["json_files_path"] = os.path.join(
                path, "json_files_path")
        utility.saveJsonFile(
            os.path.join(path, "configuration", "pathConfiguration.json"),
            dict_configuration_path)

    if (os.path.exists(hierarchy_path) == False):
        if (os.path.exists(os.path.join(path, "hierarchy")) == False):
            os.mkdir(os.path.join(path, "hierarchy"))
            dict_configuration_path["hierarchy_path"] = os.path.join(
                path, "hierarchy_path")
        else:
            dict_configuration_path["hierarchy_path"] = os.path.join(
                path, "hierarchy_path")
        utility.saveJsonFile(
            os.path.join(path, "configuration", "pathConfiguration.json"),
            dict_configuration_path)

    if (os.path.exists(excel_files_path) == False):
        if (os.path.exists(os.path.join(path, "excel_files")) == False):
            os.mkdir(os.path.join(path, "excel_files"))
            dict_configuration_path["excel_files_path"] = os.path.join(
                path, "excel_files_path")
        else:
            dict_configuration_path["excel_files_path"] = os.path.join(
                path, "excel_files_path")
        utility.saveJsonFile(
            os.path.join(path, "configuration", "pathConfiguration.json"),
            dict_configuration_path)