def sendemail(message): # 第三方 SMTP 服务 configPath = os.path.abspath( os.path.dirname( os.path.abspath( os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".")) + os.path.sep + ".") + "\config.ini" mail_host = Config.getEmail(configPath, "mail_host") mail_user = Config.getEmail(configPath, "mail_user") mail_pass = Config.getEmail(configPath, "mail_pass") sender = Config.getEmail(configPath, "sender") receivers = Config.getEmail(configPath, "receivers") print(mail_host, mail_user, mail_pass, sender, receivers) smtpObj = smtplib.SMTP() smtpObj.connect(mail_host, 25) # 25 为 SMTP 端口号 smtpObj.login(mail_user, mail_pass) smtpObj.sendmail(sender, receivers, message.as_string()) print("邮件发送成功")
def __init__(self, mdevice=""): #获取当前文件的上层路径 self._parentPath = os.path.abspath( os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".") #获取当前项目的根路径 self._rootPath = os.path.abspath( os.path.dirname(self._parentPath) + os.path.sep + ".") self._configPath = self._rootPath + "\config.ini" self._devicesList = Config.getValue( self._configPath, "deviceslist", ) self._packagePath = Config.getValue(self._configPath, "apkpath")[0] self._packageName = Config.getValue(self._configPath, "packname")[0] self._activityName = Config.getValue(self._configPath, "activityname")[0] self._skip_pushapk2devices = Config.getValue(self._configPath, "skip_pushapk2devices")[0] self._auto_delete_package = Config.getValue(self._configPath, "auto_delete_package")[0] self._auto_install_package = Config.getValue(self._configPath, "auto_install_package")[0] self._skip_check_of_install = Config.getValue( self._configPath, "skip_check_of_install")[0] self._skip_check_of_startapp = Config.getValue( self._configPath, "skip_check_of_startapp")[0] self._skip_performance = Config.getValue(self._configPath, "skip_performance")[0] self._storage_by_excel = Config.getValue(self._configPath, "storage_by_excel")[0] self._startTime = time.time() self._timeout_of_per_action = int( Config.getValue(self._configPath, "timeout_of_per_action")[0]) self._timeout_of_startapp = int( Config.getValue(self._configPath, "timeout_of_startapp")[0]) self._mdevice = mdevice # 处理模拟器端口用的冒号 if ":" in self._mdevice: self._nickName = self._mdevice.split(":")[1] else: self._nickName = self._mdevice self._iteration = int( Config.getValue(self._configPath, "iteration")[0]) self._allTestcase = Config.getValue(self._configPath, "testcase") try: self._testcaseForSelfDevice = Config.getTestCase( self._configPath, self._nickName) if self._testcaseForSelfDevice[0] == "": self._testcaseForSelfDevice = self._allTestcase except Exception: self._testcaseForSelfDevice = self._allTestcase self._testCasePath = Config.getValue(self._configPath, "testcasepath") if self._testCasePath[0] == "": self._testCasePath = os.path.join(self._rootPath, "TestCase") if self._activityName == "": self._activityName = APK(self.get_apkpath()).activities[0]
def set_TestCasePath(self, TestCasepath): configPath = self._configPath Config.setValue(configPath, "testcasepath", TestCasepath)
def set_packagepath(self, packagepath): configPath = self._configPath Config.setValue(configPath, "apkpath", packagepath)
def set_packagename(self, packagename): configPath = self._configPath Config.setValue(configPath, "packname", packagename)
def __init__(self, mdevice=""): #获取当前文件的上层路径 self._parentPath = os.path.abspath( os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".") #获取当前项目的根路径 self._rootPath = os.path.abspath( os.path.dirname(self._parentPath) + os.path.sep + ".") self._configPath = self._rootPath + "\config.ini" self._devicesList = Config.getValue( self._configPath, "deviceslist", ) self._packagePath = Config.getValue(self._configPath, "apkpath")[0] self._packageName = Config.getValue(self._configPath, "packName")[0] self._needClickInstall = Config.getValue(self._configPath, "needclickinstall")[0] self._needClickStartApp = Config.getValue(self._configPath, "needclickstartapp")[0] self._startTime = time.time() self._timeoutAction = int( Config.getValue(self._configPath, "timeoutperaction")[0]) self._timeoutStartApp = int( Config.getValue(self._configPath, "timeoutofstartapp")[0]) self._mdevice = mdevice # 处理模拟器端口用的冒号 if ":" in self._mdevice: self._nickName = self._mdevice.split(":")[1] else: self._nickName = self._mdevice self._iteration = int( Config.getValue(self._configPath, "iteration")[0]) self._allTestcase = Config.getValue(self._configPath, "testcase") try: self._testcaseForSelfDevice = Config.getTestCase( self._configPath, self._nickName) if self._testcaseForSelfDevice[0] == "": self._testcaseForSelfDevice = self._allTestcase except Exception: self._testcaseForSelfDevice = self._allTestcase self._testCasePath = Config.getValue(self._configPath, "testcasepath") if self._testCasePath[0] == "": self._testCasePath = os.path.join(self._rootPath, "TestCase")