Esempio n. 1
0
 def __init__(self):
     self.fkctl = FileChecKController()
     if self.fkctl.is_has_file("allpath.ini"):
         fp = self.fkctl.get_fileabspath()
     self.cfgctl = ConfigController(fp)
     self.log4py = LoggingController()
     self.pro_path = self.fkctl.get_project_path()
Esempio n. 2
0
class GetAllPathController(object):
    def __init__(self):
        self.fkctl = FileChecKController()
        if self.fkctl.is_has_file("allpath.ini"):
            fp = self.fkctl.get_fileabspath()
        self.cfgctl = ConfigController(fp)
        self.log4py = LoggingController()
        self.pro_path = self.fkctl.get_project_path()

    def get_dumpxml_path(self):
        self.log4py.info("executive -get_dumpxml_path- function ")
        path = os.path.join(self.pro_path, self.cfgctl.get("dumpxmlPath", "dumpxmlPath"))
        if PATH(path):
            self.log4py.info("获取 %s"%path)
            return path
        return None

    def get_htmlreport_path(self):
        self.log4py.info("executive -get_htmlreport_path- function ")
        path = os.path.join(self.pro_path, self.cfgctl.get("htmlreportPath", "htmlreportPath"))
        if PATH(path):
            self.log4py.info("获取 %s" % path)
            return path
        return None

    def get_logs_path(self):
        self.log4py.info("executive -get_logs_path- function ")
        path = os.path.join(self.pro_path, self.cfgctl.get("logsPath", "logsPath"))
        if PATH(path):
            if not os.path.exists(path):
                os.makedirs(path)
            self.log4py.info("获取 %s" % path)
            return path
        return None

    def get_capture_path(self):
        self.log4py.info("executive get_logs_path function ")
        path = os.path.join(self.pro_path, self.cfgctl.get("capturePath", "capturePath"))
        if PATH(path):
            self.log4py.info("获取 %s" % path)
            return path
        return None

    def get_appium_logs_path(self):
        self.log4py.info("executive  get_logs_path  function ")
        path = os.path.join(self.pro_path, self.cfgctl.get("appiumlogPath", "appiumlogPath"))
        if PATH(path):
            if not os.path.exists(path):
                os.makedirs(path)
            self.log4py.info("获取到appium服务的日志路径 %s" % path)
            return path.replace("\\", "/")
        return None
Esempio n. 3
0
 def get_appium_port(self, sno):
     """
     这里读取启动服务时生成的那个ini配置文件,读取其中sno对应的状态及服务的port
     :param sno:
     :return:
     """
     path = (
         os.getcwd()).split('src')[0] + "\\testconfig\\appiumService.ini"
     ff = ConfigController(path)
     try:
         port = ff.get(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. 4
0
 def __init__(self):
     self.logger = LoggingController()
     self.fc = FileChecKController()
     boolean = self.fc.is_has_file("db.ini")
     if boolean:
         self.inipath = self.fc.get_fileabspath()
     self.conf = ConfigController(self.inipath)
     self.host = str(self.conf.get("dbset", "host"))
     self.port = int(self.conf.get("dbset", "port"))
     self.user = str(self.conf.get("dbset", "user"))
     self.passwd = str(self.conf.get("dbset", "passwd"))
     self.db = str(self.conf.get("dbset", "db"))
     self.charset = str(self.conf.get("dbset", "charset"))
     self.conn = mysqldb.Connect(self.host, self.user, self.passwd, self.db,
                                 self.port, self.charset)
     self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db +
                       self.charset)
Esempio n. 5
0
class MySQLController(object):
    def __init__(self):
        self.logger = LoggingController()
        self.fc = FileChecKController()
        boolean = self.fc.is_has_file("db.ini")
        if boolean:
            self.inipath = self.fc.get_fileabspath()
        self.conf = ConfigController(self.inipath)
        self.host = str(self.conf.get("dbset", "host"))
        self.port = int(self.conf.get("dbset", "port"))
        self.user = str(self.conf.get("dbset", "user"))
        self.passwd = str(self.conf.get("dbset", "passwd"))
        self.db = str(self.conf.get("dbset", "db"))
        self.charset = str(self.conf.get("dbset", "charset"))
        self.conn = mysqldb.Connect(self.host, self.user, self.passwd, self.db,
                                    self.port, self.charset)
        self.logger.debug("数据库初始化完成" + self.host + str(self.port) + self.db +
                          self.charset)

    def execute_select(self, sql):
        cursor = self.conn.cursor()
        try:
            cursor.execute(sql)
            self.logger.debug("check_acct_available :" + sql)
            res = cursor.fetchall()
            if len(res) < 1:
                self.logger.error("%s执行查询内容不存在" % sql)
            return res
        finally:
            cursor.close()
        return None

    def execute_add_one(self, sql):
        cursor = self.conn.cursor()  #操作数据库的游标
        try:
            cursor.execute(sql)  #执行sql语句
            if cursor.rowcount == 1:
                self.logger.debug("%s添加成功" % sql)
                self.conn.commit()  #执行成功后向数据库进行提交
                return True
        except Exception, e:
            self.conn.rollback()
            self.logger.error("插入数据出现错误" + str(e))
        finally:
def html_reporter():
    logger = LoggingController()
    fc = FileChecKController()
    pro_path = fc.getProjectPath()
    boolean = fc.is_has_file("framework.ini")
    if boolean:
        inipath = fc.get_fileabspath()
        fw_conf = ConfigController(inipath)
    htmlrp_path = fw_conf.get("htmlreportPath", "htmlreportPath")
    htmreportl_abs_path = os.path.join(pro_path,htmlrp_path)
    timecurrent = DateTimeManager().formatedTime("%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))
Esempio n. 7
0
 def __init__(self):
     self.fc = FileChecKController()
     bools = self.fc.is_has_file("email.ini")
     if bools:
         fp = self.fc.get_fileabspath()
         conf = ConfigController(fp)
         self.smtp_host = conf.get("emails", "smtp_host")
         self.pop3_host = conf.get("emails", "pop3_host")
         self.receiver = conf.get("emails", "receiver").split(",")
         self.receiver_pa = conf.get("emails", "receiver_pa")
         self.sender = conf.get("emails", "sender")
         self.sender_pa = conf.get("emails", "sender_pa")
     self.log4py = LoggingController()
Esempio n. 8
0
 def __init__(self):
     path = (os.getcwd()).split('src')[0] + "\\testconfig\\run.ini"
     self.cf = ConfigController(path)
Esempio n. 9
0
class InitConfiger(object):
    def __init__(self):
        path = (os.getcwd()).split('src')[0] + "\\testconfig\\run.ini"
        self.cf = ConfigController(path)

    def get_run_conf(self):
        section = "run"
        try:
            # 是否是第一次跑,或者是重新跑,为0时会重新安装指定apk,并执行任务;为1时直接启动安装的app进行任务操作
            is_first = self.cf.get(section, "isFirst")
            # app的包名
            pkg_name = self.cf.get(section, "pkgName")
            # 启动app的main activity
            launch_activity = self.cf.get(section, "launchActivity")
            # 自动化启动app时,需要这个等待来做缓冲,避免启动页面挡住操作
            wait_activity = self.cf.get(section, "waitActivity")
            # 到isFirst为0时,就进行安装操作
            apk_file_path = self.cf.get(section, "apkFilePath")
        except Exception as e:
            return None
        return {
            "is_first": is_first,
            "pkg_name": pkg_name,
            "launch_activity": launch_activity,
            "wait_activity": wait_activity,
            "apk_file_path": apk_file_path
        }

    def set_run_conf(self, is_first, pkg_name, launch_activity, wait_activity,
                     apk_file_path):
        flag = False
        section = "run"
        try:
            self.cf.set(section, "isFirst", is_first)
            self.cf.set(section, "pkgName", pkg_name)
            self.cf.set(section, "launchActivity", launch_activity)
            self.cf.set(section, "waitActivity", wait_activity)
            self.cf.get(section, "apkFilePath", apk_file_path)
            flag = True
        except Exception as e:
            return None
        return flag

    def get_desired_caps_conf(self):
        section = "desired_caps"
        # 这些参数都是启动app时需要的,但是在代码读取参数的时候,不一定都读取,因为有些参数不是固定的
        dc = {}
        try:
            dc["automationName"] = self.cf.get(section, "automationName")
            dc["platformName"] = self.cf.get(section, "platformName")
            # dc["app"] = self.cf.get(section, "app")
            dc["appPackage"] = self.cf.get(section, "appPackage")
            dc["appActivity"] = self.cf.get(section, "appActivity")
            dc["noSign"] = self.cf.get(section, "noSign")
            dc["unicodeKeyboard"] = self.cf.get(section, "unicodeKeyboard")
            dc["resetKeyboard"] = self.cf.get(section, "resetKeyboard")
        except Exception as e:
            return None
        return dc