示例#1
0
def PreProcess(log_dir=None):
    current_path_file = temp_ini_file
    ConfigModule.clean_config_file(current_path_file)
    ConfigModule.add_section("sectionOne", current_path_file)

    if not ConfigModule.has_section("Selenium_driver_paths"):
        ConfigModule.add_section("Selenium_driver_paths")
        ConfigModule.add_config_value("Selenium_driver_paths", "chrome_path",
                                      "")
        ConfigModule.add_config_value("Selenium_driver_paths", "firefox_path",
                                      "")
        ConfigModule.add_config_value("Selenium_driver_paths", "edge_path", "")
        ConfigModule.add_config_value("Selenium_driver_paths", "opera_path",
                                      "")
        ConfigModule.add_config_value("Selenium_driver_paths", "ie_path", "")
    if not ConfigModule.get_config_value("Selenium_driver_paths",
                                         "electron_chrome_path"):
        ConfigModule.add_config_value("Selenium_driver_paths",
                                      "electron_chrome_path", "")

    # If `log_dir` is not specified, then store all logs inside Zeuz Node's
    # "AutomationLog" folder
    if log_dir is None:
        log_dir = temp_ini_file.parent

    ConfigModule.add_config_value(
        "sectionOne",
        "temp_run_file_path",
        str(log_dir),
        current_path_file,
    )
    ConfigModule.add_config_value("sectionOne", "sTestStepExecLogId",
                                  "node_cli", temp_ini_file)
    def getLocalUser(self):
        """
        :return: returns the local pc name
        """
        try:
            # node_id_file_path = os.path.join(FL.get_home_folder(), os.path.join('Desktop', 'node_id.conf'))
            # node_id_file_path = os.path.join (os.path.realpath(__file__).split("Framework")[0] , os.path.join ('node_id.conf'))

            node_id_file_path = Path(
                os.path.abspath(__file__).split("Framework")[0]) / Path(
                    "node_id.conf")

            if os.path.isfile(node_id_file_path):
                unique_id = ConfigModule.get_config_value(
                    "UniqueID", "id", node_id_file_path)
                if unique_id == "":
                    ConfigModule.clean_config_file(node_id_file_path)
                    ConfigModule.add_section("UniqueID", node_id_file_path)
                    unique_id = uuid.uuid4()
                    unique_id = str(unique_id)[:10]
                    ConfigModule.add_config_value("UniqueID", "id", unique_id,
                                                  node_id_file_path)
                    machine_name = (ConfigModule.get_config_value(
                        "Authentication", "username") + "_" + str(unique_id))
                    return machine_name[:100]
                machine_name = (ConfigModule.get_config_value(
                    "Authentication", "username") + "_" + str(unique_id))
            else:
                # create the file name
                f = open(node_id_file_path, "w")
                f.close()
                unique_id = uuid.uuid4()
                unique_id = str(unique_id).lower()[:10]
                ConfigModule.add_section("UniqueID", node_id_file_path)
                ConfigModule.add_config_value("UniqueID", "id", unique_id,
                                              node_id_file_path)
                machine_name = (ConfigModule.get_config_value(
                    "Authentication", "username") + "_" + str(unique_id))
            return machine_name[:100]

        except Exception:
            ErrorMessage = "Unable to set create a Node key.  Please check class MachineInfo() in commonutil"
            return Exception_Handler(sys.exc_info(), None, ErrorMessage)
    def getUniqueId(self):
        """
        This function is not used any more
        :return: returns the local pc unique ID
        """
        try:
            node_id_file_path = Path(
                os.path.abspath(__file__).split("Framework")[0]) / Path(
                    "node_id.conf")

            if os.path.isfile(node_id_file_path):
                unique_id = ConfigModule.get_config_value(
                    "UniqueID", "id", node_id_file_path)
                if unique_id == "":
                    ConfigModule.clean_config_file(node_id_file_path)
                    ConfigModule.add_section("UniqueID", node_id_file_path)
                    unique_id = uuid.uuid4()
                    unique_id = str(unique_id)[:10]
                    ConfigModule.add_config_value("UniqueID", "id", unique_id,
                                                  node_id_file_path)
                    machine_name = str(unique_id)
                    return machine_name[:100]
                machine_name = str(unique_id)
            else:
                # create the file name
                f = open(node_id_file_path, "w")
                f.close()
                unique_id = uuid.uuid4()
                unique_id = str(unique_id)[:10]
                ConfigModule.add_section("UniqueID", node_id_file_path)
                ConfigModule.add_config_value("UniqueID", "id", unique_id,
                                              node_id_file_path)
                machine_name = str(unique_id)
            return machine_name[:100]

        except Exception:
            ErrorMessage = "Unable to set create a Node key.  Please check class MachineInfo() in commonutil"
            return Exception_Handler(sys.exc_info(), None, ErrorMessage)
 def setLocalUser(self, custom_id):
     """
     Set node_id from node_cli Command Line Interface and returns local userid
     """
     try:
         node_id_file_path = Path(
             os.path.abspath(__file__).split("Framework")
             [0]) / "node_id.conf"
         if os.path.isfile(node_id_file_path):
             ConfigModule.clean_config_file(node_id_file_path)
             ConfigModule.add_section("UniqueID", node_id_file_path)
             custom_id = custom_id.lower()[:10]
             ConfigModule.add_config_value("UniqueID", "id", custom_id,
                                           node_id_file_path)
         else:
             f = open(node_id_file_path, "w")
             f.close()
             ConfigModule.add_section("UniqueID", node_id_file_path)
             custom_id = custom_id.lower()[:10]
             ConfigModule.add_config_value("UniqueID", "id", custom_id,
                                           node_id_file_path)
     except Exception:
         ErrorMessage = "Unable to set create a Node key.  Please check class MachineInfo() in commonutil"
         return Exception_Handler(sys.exc_info(), None, ErrorMessage)