Beispiel #1
0
 def __init__(self, excelfilename):
     self.excelfilename = excelfilename
     fc = FileInspector()
     boolean = fc.is_has_file(excelfilename)
     if boolean:
         self.excel_path = fc.get_file_abspath()
     self.log4py = LoggingPorter()
 def __init__(self):
     fc = FileInspector()
     self.filepath = None
     self.propath = None
     boolean = fc.is_has_file("接口测试用例集.xlsx")
     if boolean:
         self.filepath = fc.get_file_abspath()
         self.propath = fc.get_project_path()
 def __init__(self):
     self.__fileabspath = None
     self.__projectpath = None
     self.log4py = LoggingPorter()
     fc = FileInspector()
     boolean = fc.is_has_file("owl-selenium.ini")
     if boolean:
         self.__fileabspath = fc.get_file_abspath()
         self.__projectpath = fc.get_project_path()
     self.conf = ConfigReader(self.__fileabspath)
    def __init__(self):
        self.fkctl = FileInspector()

        if self.fkctl.is_has_file("owl-appium.ini"):
            fp = self.fkctl.get_file_abspath()
            self.cfg = ConfigReader(fp)
        self.log4py = LoggingPorter()
        self.log4py.info("-----配置文件操作开始-----")
        self.f_path = os.path.join(
            self.fkctl.get_project_path(),
            self.cfg.get_value("ResultPath", "appiumService"))
Beispiel #5
0
 def __init__(self):
     self.fc = FileInspector()
     bools = self.fc.is_has_file("owl-framework.ini")
     if bools:
         fp = self.fc.get_file_abspath()
         conf = ConfigReader(fp)
         self.smtp_host = conf.get_value("email", "smtp_host")
         self.pop3_host = conf.get_value("email", "pop3_host")
         self.receiver = conf.get_value("email", "receiver").split(",")
         self.receiver_pa = conf.get_value("email", "receiver_pa")
         self.sender = conf.get_value("email", "sender")
         self.sender_pa = conf.get_value("email", "sender_pa")
         self.report_path = os.path.join(
             self.fc.get_project_path(),
             conf.get_value("ResultPath", "htmlreportPath"))
     self.log4py = LoggingPorter()
Beispiel #6
0
class EmailController(object):
    def __init__(self):
        self.fc = FileInspector()
        bools = self.fc.is_has_file("owl-framework.ini")
        if bools:
            fp = self.fc.get_file_abspath()
            conf = ConfigReader(fp)
            self.smtp_host = conf.get_value("email", "smtp_host")
            self.pop3_host = conf.get_value("email", "pop3_host")
            self.receiver = conf.get_value("email", "receiver").split(",")
            self.receiver_pa = conf.get_value("email", "receiver_pa")
            self.sender = conf.get_value("email", "sender")
            self.sender_pa = conf.get_value("email", "sender_pa")
            self.report_path = os.path.join(
                self.fc.get_project_path(),
                conf.get_value("ResultPath", "htmlreportPath"))
        self.log4py = LoggingPorter()

    def send_email_is_html(self):
        latestfpath, fname, currentfolder = self.fc.get_latest_file(
            self.report_path)
        msgRoot = MIMEMultipart('related')
        ff = open(latestfpath, 'rb')
        message = MIMEText(ff.read(), 'html', 'utf-8')
        ff.close()
        message['From'] = self.sender
        #message['To'] = self.receiver
        subject = '实验室数字化平台-自动化测试报告'
        message['Subject'] = Header(subject, 'utf-8')
        msgRoot.attach(message)
        try:
            smtpObj = smtplib.SMTP()
            smtpObj.connect(self.smtp_host)
            smtpObj.login(self.sender, self.sender_pa)
            smtpObj.sendmail(self.sender, self.receiver, msgRoot.as_string())
            self.log4py.debug("SendEmail_withFile邮件发送成功")
            smtpObj.close()
        except Exception, e:
            print e
            self.log4py.error("Error: 无法发送邮件::" + str(e))
class DumpMobileInfo(object):
    def __init__(self):
        self.json_obj = None
        self.fp = FileInspector()
        self.json_file_path = self.fp.get_devices_info_file_path()

    def load_json(self, json_file_path):
        fin = open(json_file_path, "r")
        try:
            self.json_obj = json.load(fin)
        except ValueError, e:
            self.json_obj = {}
        fin.close()
        return self.json_obj
Beispiel #8
0
def html_reporter():
    logger = LoggingPorter()
    fc = FileInspector()
    pro_path = fc.get_project_path()
    boolean = fc.is_has_file("owl-framework.ini")
    if boolean:
        inipath = fc.get_file_abspath()
        cf = ConfigReader(inipath)
    htmlrp_path = cf.get_value("ResultPath", "htmlreportPath")
    htmreportl_abs_path = os.path.join(pro_path, htmlrp_path)
    timecurrent = formated_time("%Y-%m-%d-%H-%M-%S")
    logger.debug("=====创建了一个html文件报告,路径是::" + htmreportl_abs_path)
    file_path = str(
        htmreportl_abs_path) + timecurrent + "-LDP-TestingRreporter.html"
    try:
        if os.path.exists(file_path):
            html_obj = open(file_path, "a")  # 打开文件   追加
            return html_obj
        else:
            html_obj = file(file_path, "wb+")
            return html_obj
    except Exception, e:
        logger.error("创建html_reporter出现错误" + str(e))
class CreateConfigFile(object):
    def __init__(self):
        self.fkctl = FileInspector()

        if self.fkctl.is_has_file("owl-appium.ini"):
            fp = self.fkctl.get_file_abspath()
            self.cfg = ConfigReader(fp)
        self.log4py = LoggingPorter()
        self.log4py.info("-----配置文件操作开始-----")
        self.f_path = os.path.join(
            self.fkctl.get_project_path(),
            self.cfg.get_value("ResultPath", "appiumService"))

    def __del__(self):
        self.log4py.info("-----配置文件操作结束-----")

    def set_appium_uuids_ports(self, device_list, port_list):
        """
        遍历list,按照下表进行对应映射
        :param device_lsit: 手机uuid
        :param port_list: pc启动的appium服务端口
        """
        bol = self.create_config_file(self.f_path)
        if bol:
            self.log4py.info("创建appiumService.ini文件成功:{}".format(self.f_path))
            ap = ConfigReader(self.f_path)
            if len(device_list) > 0 and len(port_list) > 0:
                for i in range(len(device_list)):
                    filed = device_list[i]
                    key = filed
                    value = port_list[i]
                    # 因为是覆盖写入,没有section,需要先添加再设置, 初始化的服务都加一个run的标识
                    ap.add_section_key_value(filed, key, value)
                    ap.set_value(filed, "run", "0")
                ap.flush()
                self.log4py.debug(
                    "设备sno与appium服务端口映射已写入appiumService.ini配置文件:{}--{}".format(
                        key, value))

    def set_appium_uuid_port(self, device, port, bp):
        """
        如果这样一个一个的写入到配置文件中,是追加还是覆盖?如果是覆盖的,服务启动完成后就剩一个配置,所以不行
        如果是追加,需要判断配置文件中是否已经有了相同的section,有就更新,没有就添加
        :param device: 手机uuid
        :param port pc启动的appium服务端口
        """
        bol = self.create_config_file(self.f_path)
        if bol:
            if device is not None and port is not None:
                ap = ConfigReader(self.f_path)
                sec = device
                key = device
                value = port
                if ap.had_section(sec):
                    ap.set_value(sec, key, value)
                    ap.set_value(sec, "bp", bp)
                    ap.set_value(sec, "run", "0")
                else:
                    ap.add_section_key_value(sec, key, value)
                    ap.set_value(sec, "bp", bp)
                    ap.set_value(sec, "run", "0")
                ap.flush()
                self.log4py.debug(
                    "设备sno与appium服务端口映射已写入appiumService.ini配置文件:{}--{}".format(
                        key, value))

    def create_config_file(self, path):
        """
        如果path这个文件不存在,就创建这个文件;存在就清空文件
        :param path: 是一个文件的绝对路径
        :return: 
        """
        if os.path.exists(path) and os.path.isfile(path):
            return True
        dir_name = os.path.dirname(path)
        if not os.path.exists(dir_name):
            os.makedirs(dir_name)
        f = open(path, "wb")
        f.close()
        if os.path.exists(path) and os.path.isfile(path):
            return True
        return False

    def get_all_appium_server_port(self):

        port_list = []
        if os.path.exists(self.f_path):
            ap = ConfigReader(self.f_path)
            section_list = ap.get_sections()
            for sl in section_list:
                port_list.append(ap.get_value(sl, sl))
                port_list.append(ap.get_value(sl, "bp"))
        return port_list

    def get_appium_logs_path(self):
        path = os.path.join(self.fkctl.get_project_path(),
                            self.cfg.get_value("ResultPath", "appiumlogPath"))
        if PATH(path):
            if not os.path.exists(path):
                os.makedirs(path)
            self.log4py.info("获取到appium服务的日志绝对路径 %s" % path)
            return path.replace("\\", "/")
        return None
 def __init__(self):
     self.json_obj = None
     self.fp = FileInspector()
     self.json_file_path = self.fp.get_devices_info_file_path()