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))
Esempio n. 2
0
 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 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 __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"))
Esempio n. 5
0
 def __get_appium_port(self, sno):
     """
     这里读取启动服务时生成的那个ini配置文件,读取其中sno对应的状态及服务的port
     :param sno:
     :return:
     """
     ff = ConfigReader(self.run_cfg.properties.appiumService)
     try:
         port = ff.get_value(sno, sno)
         if port:
             self.log4py.info("获取到{}设备对应的appium服务端口{}".format(sno, port))
         return port
     except Exception as e:
         self.log4py.debug("{}设备对应的appium未启动".format(sno))
         return None
Esempio n. 6
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()
 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))
Esempio n. 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))