def __init__(self, database=None): dbtest = ReadConfig(database) self.host = dbtest.get_db('host') self.username = dbtest.get_db('username') self.password = dbtest.get_db('password') self.port = dbtest.get_db('port') self.database = dbtest.get_db('database')
def _Scrm_login(self, username, password, ): userName_loc = (By.NAME, 'username') # 密码 password_loc = (By.NAME, 'password') # 验证码 captcha_loc = (By.NAME, 'captcha') # 登录按钮 login_btn_loc = (By.XPATH, '//*[@id="app"]/div/div[2]/div/form/button/span') sql = "SELECT * from sys_captcha ORDER BY expire_time desc limit 1" baseUrl = ReadConfig() url = baseUrl.get_http('baseUrl') self.driver.get(url) sleep(3) self.find_emelemt(*userName_loc).send_keys(username) self.find_emelemt(*password_loc).send_keys(password) readSql = Read_sql(sql) code = readSql.sqlExecute() vsCode = code[0]['code'] self.find_emelemt(*captcha_loc).send_keys(vsCode) # 点击登录 self.find_emelemt(*login_btn_loc).click()
def get_online_devices(): '''get the devices from ATX-Server return alive devices''' devices = ATX_Server(ReadConfig().get_server_url()).online_devices() print('Start check %s devices on ATX-Server' % len(devices)) if devices: pool = Pool(processes=len(devices)) tmp_list = [] for run in devices: tmp_list.append(pool.apply_async(check_alive, args=(run, ))) pool.close() pool.join() devices_list = [] for i in tmp_list: if i.get(): devices_list.append(i.get()) return devices_list else: raise Exception('ATX-Server has no online device!!! ')
def get_devices(): '''get the devices from Pubilc/Config.ini devices list return alive devices''' devices_ip = ReadConfig().get_devices_ip() print('Connect devices from Config devices IP list %s' % devices_ip) devices_list = [] for i in devices_ip: try: device = u2.connect(i) # device.reset_uiautomator() if device.agent_alive: device.healthcheck() if device.alive: dict_tmp = device.device_info dict_tmp['ip'] = i devices_list.append(dict_tmp) else: print('The IP %s device is not alive,please checkout!' % i) except Exception as e: print( 'Raise ERROR %s\nThe IP %s device is not alive,please checkout!' % (e, i)) return devices_list
def get_online_devices(): '''get the devices from ATX-Server return alive devices''' devices = ATX_Server(ReadConfig().get_server_url()).online_devices() # print('Connect devices from Config devices IP list %s' % devices_ip) devices_list = [] if devices: for i in devices: try: device = u2.connect(i['ip']) if device.agent_alive: device.healthcheck() if device.alive: devices_list.append(i) else: print('The device %s is not alive,please checkout!' % i['udid']) except Exception as e: print( 'Raise ERROR %s\nThe IP %s device is not alive,please checkout!' % (e, i['udid'])) return devices_list else: raise Exception('ATX-Server has no online device!!! ')
shutil.make_archive(GRANDFA + '/Result/picture', 'zip', GRANDFA + '/Result/caseScreenshot') with open('../result/picture.zip', 'rb') as f: mimeZip = MIMEBase('file', 'zip', filename='picture.zip') mimeZip.add_header('Content-Disposition', 'attachment', filename='picture.zip') mimeZip.add_header('Content-ID', '<0>') mimeZip.add_header('X-Attachment-Id', '0') # 把附件的内容读进来: mimeZip.set_payload(f.read()) # 用Base64编码: encoders.encode_base64(mimeZip) # 添加到MIMEMultipart: msg.attach(mimeZip) server = smtplib.SMTP(self.smtp_server, 25) #server.set_debuglevel(1) server.starttls() server.login(self.from_addr, self.password) server.sendmail(self.from_addr, [self.to_addr], msg.as_string()) server.quit() self.log.info("邮件发送成功,请及时查收!!!") except: self.log.info("邮件发送失败") if __name__ == '__main__': to_email = ReadConfig().get_email("email") # 获取需要发送的邮箱 AutomaticeSendOfMail(to_email).sendMail()