Esempio n. 1
0
    def logger(self):
        """
        封装一个记录的日志方法
        :return:
        """

        # 创建一个logger
        logger = logging.getLogger("myLogger")
        logger.setLevel(logging.DEBUG)
        # 创建一个handler,用于写入日志文件
        conf = Config("FilePath")
        log_path=conf.get_path_config(self.logs)

        log_file = logging.FileHandler(SystemOs().sys_path(log_path))
        log_file.setLevel(logging.DEBUG)
        # 再创建一个handler,用于输出到控制台
        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG)

        # 定义handler的输出格式
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        log_file.setFormatter(formatter)
        console.setFormatter(formatter)

        # 给logger添加handler
        logger.addHandler(log_file)
        logger.addHandler(console)
        return logger
Esempio n. 2
0
 def childConfigXML(self, Pageskeyword, UIElementkeyword):
     confFile = self.rootChildConfigPath()
     config2 = Config("XMLFilePath", confFile)
     filepath = config2.get_path_config("uigoods")
     filepath = SystemOs().sys_path(filepath)
     xmlspath = XmlUtil(filepath)
     # 获取XML中相关信息
     xmls = xmlspath.xml_parsing(Pageskeyword, UIElementkeyword)
     return xmls
Esempio n. 3
0
 def childConfigXlsx(self,sheet,dictData):
     # "获取子配置文件中信息",loginXlsx
     confFile = self.rootChildConfigPath()
     config1= Config("XlsxFilePath",confFile)
     loginXlsx = config1.get_path_config("user_login")
     loginXlsx = SystemOs().sys_path(loginXlsx)
     #dictData = {"userName": 3, "password": 4, "expected": 6}
     excelUtil = DoExcel(loginXlsx, sheet).do_excel(**dictData)
     return excelUtil
Esempio n. 4
0
 def childCofigLeading_inEcxel(self):
     """
     导入虚拟文件模板
     :return:
     """
     confFile = self.rootChildConfigPath()
     config5 = Config("XlsxFilePath", confFile)
     Leading_inEcxel = config5.get_path_config("redeem_code_template")
     return Leading_inEcxel
Esempio n. 5
0
 def childConfigPublicImg(self):
     """
     获取公共上传图片地址
     :return:
     """
     confFile = self.rootChildConfigPath()
     config4 = Config("PublicImg", confFile)
     public_img = config4.get_path_config("goodsImg")
     return public_img
Esempio n. 6
0
    def childConfigXlsx(self, sheet, dictData):
        # "获取子配置文件中信息",Excel文件内容
        confFile = self.rootChildConfigPath()

        config1 = Config("XlsxFilePath", confFile)

        goodsObjectXlsx = config1.get_path_config("goods_object")
        goodsObjectXlsx = SystemOs().sys_path(goodsObjectXlsx)

        excelUtil = DoExcel(goodsObjectXlsx, sheet).do_excel(**dictData)
        return excelUtil
Esempio n. 7
0
 def childConfigImgPath(self):
     """
     获取图片路径,并新建以日期为基础的文件目录名 例如: img/2019-01-01/
     :return:
     """
     confFile = self.rootChildConfigPath()
     config3 = Config("ImgPath", confFile)
     img_path = config3.get_path_config("error_img")
     data_path = TestDateTime().local_day()
     img_path = SystemOs().sys_path(img_path, data_path)
     SystemOs().mkdirs_file(img_path)
     return img_path
Esempio n. 8
0
 def childConfigTestFile(self):
     # "获取子配置文件中信息",testFile
     confFile = self.rootChildConfigPath()
     config1 = Config("TestFile", confFile)
     testFile = config1.get_path_config("mprTestFile")
     return testFile
Esempio n. 9
0
 def childConfigReport(self):
     # "获取子配置文件中信息",report
     confFile = self.rootChildConfigPath()
     config1= Config("ReportFile",confFile)
     mpreport= config1.get_path_config("mpReport")
     return mpreport