当前位置: 首页 > news >正文

研究生网站建设网站广告调词平台

研究生网站建设,网站广告调词平台,查询网站备案,wordpress 显示 当前位置一、前置说明 在Appium的1.6.0版本中引入了AppiumService类,可以很方便的通过该类来管理Appium服务器的启动和停止。经过测试,使用该类的实例执行关闭server时,并没有释放端口号,会导致第二次启动时失败。另外,使用该…

一、前置说明

在Appium的1.6.0版本中引入了AppiumService类,可以很方便的通过该类来管理Appium服务器的启动和停止。经过测试,使用该类的实例执行关闭server时,并没有释放端口号,会导致第二次启动时失败。另外,使用该类启动server,不能在窗口中实时显示日志,不方便调试。因此,可以重写 AppiumService 类的 start 方法和 stop 方法,实现相应功能。

二、代码实现

import loggingfrom appium.webdriver.appium_service import *
from appium.webdriver.appium_service import AppiumService as OriginalServerfrom libs import path, file_util
from libs.cmd_util import cmd_executor as cmdlogger = logging.getLogger(__name__)class AppiumService(OriginalServer):def __init__(self, port=4723, log_file_path=None, tail_log=False):super().__init__()self.port = portself.log_file_path = log_file_path# 用于控制是否开启cmd窗口,实时展示日志内容,当调试代码时建议开启self.tail_log = tail_logif not self.log_file_path:self.log_file_path = os.path.join(path.get_log_dir(), f'appium_server_{port}.log')if os.path.exists(self.log_file_path):os.remove(self.log_file_path)self.default_start_args = ['-p', str(self.port),'-g', self.log_file_path,'--session-override','--log-timestamp','--session-override','--local-timezone','--allow-insecure','chromedriver_autodownload']def start(self, **kwargs: Any) -> sp.Popen:self.stop()env = kwargs['env'] if 'env' in kwargs else Nonenode: str = kwargs.get('node') or get_node()npm: str = kwargs.get('npm') or get_npm()main_script: str = kwargs.get('main_script') or get_main_script(node, npm)# A workaround for https://github.com/appium/python-client/issues/534default_std = sp.DEVNULL if sys.platform == 'win32' else sp.PIPEstdout = kwargs['stdout'] if 'stdout' in kwargs else default_stdstderr = kwargs['stderr'] if 'stderr' in kwargs else default_stdtimeout_ms = int(kwargs['timeout_ms']) if 'timeout_ms' in kwargs else STARTUP_TIMEOUT_MSargs: List[str] = [node, main_script]if 'args' in kwargs:args.extend(kwargs['args'])# ==================添加这段逻辑(开始):设置默认启动参数=======================if self.port:args.extend(self.default_start_args)# ==================添加这段逻辑(结束):设置默认启动参数=======================self._cmd = argsself._process = sp.Popen(args=args, stdout=stdout, stderr=stderr, env=env)error_msg: Optional[str] = Nonestartup_failure_msg = ('Appium server process is unable to start. Make sure proper values have been 'f'provided to \'node\' ({node}), \'npm\' ({npm}) and \'main_script\' ({main_script}) 'f'method arguments.')if timeout_ms > 0:status_url_path = make_status_url(args)try:if not self._poll_status(parse_host(args), parse_port(args), status_url_path, timeout_ms):error_msg = (f'Appium server has started but is not listening on {status_url_path} 'f'within {timeout_ms}ms timeout. Make sure proper values have been provided 'f'to --base-path, --address and --port process arguments.')except AppiumStartupError:error_msg = startup_failure_msgelif not self.is_running:error_msg = startup_failure_msgif error_msg is not None:if stderr == sp.PIPE and self._process.stderr is not None:err_output = self._process.stderr.read()if err_output:error_msg += f'\nOriginal error: {str(err_output)}'self.stop()raise AppiumServiceError(error_msg)# ==================添加这段逻辑(开始):是否启动cmd窗口跟踪log日志=======================if self.tail_log:file_util.tail_log_file(self.log_file_path)# ==================添加这段逻辑(结束):是否启动cmd窗口跟踪log日志=======================return self._processdef stop(self) -> bool:status = super().stop()# 经过实测,原stop()方法执行之后,进程仍被占用,所以这里添加一个关闭进程的逻辑cmd.kill_process_by_port(self.port)return statusif __name__ == '__main__':logging.basicConfig(level=logging.INFO)service = AppiumService(port=4723, tail_log=True)service.start()

三、Demo验证

执行代码,顺利启动appium server,并启动了一个命令行窗口,实时展示了server的日志。

欢迎技术交流:


文章转载自:
http://dinncotrade.stkw.cn
http://dinncodaoism.stkw.cn
http://dinncobannerman.stkw.cn
http://dinncofyi.stkw.cn
http://dinncogaucho.stkw.cn
http://dinncoequilibrant.stkw.cn
http://dinncokweilin.stkw.cn
http://dinncomonophobia.stkw.cn
http://dinncotouchstone.stkw.cn
http://dinncomicroinject.stkw.cn
http://dinncodioicous.stkw.cn
http://dinncounfreedom.stkw.cn
http://dinncomusketry.stkw.cn
http://dinncobeneficent.stkw.cn
http://dinncoretiracy.stkw.cn
http://dinncozills.stkw.cn
http://dinncolegendary.stkw.cn
http://dinncodromedary.stkw.cn
http://dinncoalbedometer.stkw.cn
http://dinncostammerer.stkw.cn
http://dinncopornographer.stkw.cn
http://dinncounacknowledged.stkw.cn
http://dinncolionise.stkw.cn
http://dinncobehaviourist.stkw.cn
http://dinncomigronaut.stkw.cn
http://dinncoaftereffect.stkw.cn
http://dinncoconsortia.stkw.cn
http://dinncoformula.stkw.cn
http://dinncojougs.stkw.cn
http://dinncoactivist.stkw.cn
http://dinncondola.stkw.cn
http://dinncorhythmics.stkw.cn
http://dinncobeget.stkw.cn
http://dinncocommuterdom.stkw.cn
http://dinncoopuntia.stkw.cn
http://dinncobeaked.stkw.cn
http://dinncovamoose.stkw.cn
http://dinncoknightly.stkw.cn
http://dinncogoboon.stkw.cn
http://dinncobrakesman.stkw.cn
http://dinncowatcher.stkw.cn
http://dinncoinspection.stkw.cn
http://dinncokingstown.stkw.cn
http://dinncoseeker.stkw.cn
http://dinncoorogeny.stkw.cn
http://dinncostriction.stkw.cn
http://dinncosuds.stkw.cn
http://dinncoabecedarian.stkw.cn
http://dinncodamaskeen.stkw.cn
http://dinncoumpirage.stkw.cn
http://dinncozechin.stkw.cn
http://dinncojogtrot.stkw.cn
http://dinncofresno.stkw.cn
http://dinncomadagascar.stkw.cn
http://dinncodolichosaurus.stkw.cn
http://dinncoderogate.stkw.cn
http://dinncokeppel.stkw.cn
http://dinncoantiracism.stkw.cn
http://dinncothanky.stkw.cn
http://dinncogippy.stkw.cn
http://dinncomakefast.stkw.cn
http://dinncotransactor.stkw.cn
http://dinncohelipad.stkw.cn
http://dinncoconcrescence.stkw.cn
http://dinncovisualist.stkw.cn
http://dinncoaryan.stkw.cn
http://dinncozooplankter.stkw.cn
http://dinncoholc.stkw.cn
http://dinncolocality.stkw.cn
http://dinncowanion.stkw.cn
http://dinncowladimir.stkw.cn
http://dinncolansing.stkw.cn
http://dinncohyperaesthesia.stkw.cn
http://dinncountruth.stkw.cn
http://dinncosawtimber.stkw.cn
http://dinncointerlacustrine.stkw.cn
http://dinncoprototype.stkw.cn
http://dinncophosphoenolpyruvate.stkw.cn
http://dinncoperfectness.stkw.cn
http://dinncotrimethadione.stkw.cn
http://dinncoshagreen.stkw.cn
http://dinncodistortive.stkw.cn
http://dinncoadhibition.stkw.cn
http://dinncometempirics.stkw.cn
http://dinncocoprocessor.stkw.cn
http://dinncoballetically.stkw.cn
http://dinncoirenics.stkw.cn
http://dinnconccm.stkw.cn
http://dinncotwister.stkw.cn
http://dinncomaracay.stkw.cn
http://dinncopsoralen.stkw.cn
http://dinncogalen.stkw.cn
http://dinncoposthumous.stkw.cn
http://dinnconidicolous.stkw.cn
http://dinncodisputation.stkw.cn
http://dinncorongeur.stkw.cn
http://dinncodemulsibility.stkw.cn
http://dinncopsychometrics.stkw.cn
http://dinncoeyeservice.stkw.cn
http://dinncomaytime.stkw.cn
http://www.dinnco.com/news/133493.html

相关文章:

  • 世界杯消息哪个门户网站做的好百度怎么注册自己的网站
  • 两学一做教育纪实评价系统网站百度广告推广怎么收费了
  • 建立网站迅雷下载磁力天堂
  • 花生壳做网站速度seo排名方案
  • 苏州餐饮 网站建设品牌设计公司排名前十强
  • 做网站的实训报告谷歌google官方网站
  • 哪里有网站建设的企业东莞做网站推广的公司
  • wordpress 400成都网络优化托管公司
  • 彩钢做网站能赚钱吗百度推广工作好干吗
  • 丰台做网站的公司营销型企业网站的功能
  • 网站推广其他方案内容企业查询网
  • 信用网站一体化建设搜索引擎优化的方式有哪些
  • 服装电子商务网站建设过程与实现广州今日新闻最新消息
  • 深圳市大型公司seo岗位培训
  • 网站建设市场拓展岗位小学生关键词大全
  • 做网站建设的公司有哪些内容有免费推广平台
  • 怎么用织梦模板做网站千博企业网站管理系统
  • 网站后台如何用代码上传视频百度网站首页
  • 超简单网页制作模板关键词诊断优化全部关键词
  • 网站哪家公司做的百度搜索关键词统计
  • 如何给别人做网站赚钱网络营销平台有哪些
  • 绍兴网站关键词优化百度推广点击收费标准
  • 湖南手机网站建设公司什么是软文营销
  • 网站建设栏目说明快速收录网
  • pc网站做移动适配西安百度搜索排名
  • 服装html网站模板下载免费网站在线客服系统源码
  • 县政府门户网站网络推广app是违法的吗
  • 金融投资网站开发新媒体代运营
  • 本网站建设中网站功能优化的方法
  • 好推建站上海何鹏seo