Example #1
0
import os
import logging
import time
from config import getProjectPath
from config.readConfig import readConfig
from logging.handlers import TimedRotatingFileHandler

path = getProjectPath.get_project_path()
log = readConfig().get_log()


class Logger():
    """
    Logger类
    """
    def __init__(self, logger_name='log...'):
        self.logger = logging.getLogger(logger_name)
        logging.root.setLevel(logging.NOTSET)  # 设置日志总级别,不设置默认WARNING
        self.log_path = os.path.join(path, 'report', 'log', 'logs')  # 日志文件路径
        self.log_file_name = 'logs.txt'
        self.backup_Count = 5  # log文件数量

        # 设置日志级别,日志级别:CRITICAL > ERROR > WARNING > INFO > DEBUG
        self.file_output_lever = log['file_output_lever']
        self.console_output_lever = log['console_output_lever']

        # 设置日志格式
        self.Formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    def get_logger(self):
Example #2
0
import os
from config.getProjectPath import get_project_path
from common.log import Logger

path = get_project_path()
log = Logger('common.basePage').get_logger()


class Page(object):
    def __init__(self,
                 driver,
                 img_path=os.path.join(path, 'report', 'screen_shot'),
                 uiau=None,
                 app=None):

        self.dr = driver
        self.img_path = img_path
        self.uiau = uiau
        self.app = app
Example #3
0
import cv2, os
import time
from config.getProjectPath import get_project_path
from common.log import Logger
from common.MySelenium import mySelenium

log = Logger('common.slider_captcha.py').get_logger()
path = get_project_path()  # 项目路径
captcha_background = os.path.join(path, 'report', 'screen_shot',
                                  'captcha_background.png')  # 验证码背景图
captcha_background_crop = os.path.join(
    path, 'report', 'screen_shot', 'captcha_background_crop.png')  # 裁剪后的背景图
captcha_background_canny = os.path.join(
    path, 'report', 'screen_shot', 'captcha_background_canny.png')  # 背景图canny化
captcha_puzzle = os.path.join(path, 'report', 'screen_shot',
                              'captcha_puzzle.png')  # 验证码拼图块
captcha_puzzle_crop = os.path.join(path, 'report', 'screen_shot',
                                   'captcha_puzzle_crop.png')  # 裁剪后的拼图块
captcha_puzzle_canny = os.path.join(path, 'report', 'screen_shot',
                                    'captcha_puzzle_canny.png')  # 拼图块canny化


def canny(background_crop, puzzle_crop):
    """
    匹配图片,计算缺口位置
    :param background_crop:验证码背景图
    :param puzzle_crop:验证码拼图
    :return:max_loc返回缺口坐标
    """
    imgs = []
    # 原始图像,用于展示