python:当文件中出现特定字符串时执行robot用例
2024-08-23 15:40:50
#coding:utf-8
import os
import datetime
import time def execute_rpt_db_full_effe_cainiao_city():
flag = True
while flag:
# 判断该文件是否存在
# os.path.isfile("/home/ytospid/opt/docker/jsc_spider/jsc_spider/log/call_proc.log")
# 存在则获取昨天日期字符串
yesterday = datetime.datetime.now()+ datetime.timedelta(-1)
yesterday_str = datetime.datetime.strftime(yesterday,'%Y%m%d')
# 判断该日志文件中是否包含该字符串,如果存在则表示今日数据已经爬完入库 with open('/home/ytospid/opt/docker/jsc_spider/jsc_spider/log/call_proc.log') as f:
for line in f.readlines():
if yesterday_str in line:
# 再执行30场景检查该表
os.system("robot -i rpt_db_full_effe_cainiao_city -l case30_log.html -r case30_report.html -o case30_output.xml /home/ytospid/opt/spider_monitor/菜鸟指数爬虫监控/01_测试用例/接口测试用例/菜鸟指数爬虫结果监控.txt")
# print line
print '已执行30场景'
flag = False
return 'OK'
print u'休眠5秒'
time.sleep(60)
execute_rpt_db_full_effe_cainiao_city() if __name__ == '__main__':
execute_rpt_db_full_effe_cainiao_city()
例子: 每5秒检查一次test.txt文件,如果出现“hello”,则打开计算器,
import os,time def execute(): with open('test.txt') as f:
for line in f.readlines():
if 'hello' in line:
os.system("calc.exe")
return
print '休息10秒再试试'
time.sleep(5)
execute() if __name__ == '__main__':
execute()
最新文章
- Git异常:fatal: could not create work tree dir 'XXX': No such file or directory
- 十种MYSQL显错注入原理讲解(二)
- C#设计模式-外观模式
- canvas画布在主流浏览器中的尺寸限制
- hdu 1249 三角形
- kd tree学习笔记 (最近邻域查询)
- R正则表达式的问题
- UVa 297 (四分树 递归) Quadtrees
- 【pm2】
- Jquery学习笔记:删除节点的操作
- Spring定时任务解决博客缓存数据更新问题
- c# Activex开发之HelloWorld
- (转)SimpleDateFormat使用详解
- Appium (win7系统)环境搭建----完整版
- 移动WEB 响应式设计 @media总结
- Unity3D - Animator Controller循环依赖
- windows系统下安装node
- Shell从入门到精通进阶之四:流程控制
- 通过maven profile 打包指定环境配置
- Azure IoT 技术研究系列2-设备注册到Azure IoT Hub
热门文章
- zookeeper 的 docker 镜像使用
- Appache Flume 中文介绍(转)
- 【深入ASP.NET原理系列】--Asp.Net Mvc和Asp.Net WebForm实际上共用一套ASP.NET请求管道
- springboot(二)
- hasura skor 一个pg 的event trigger 扩展
- 使用go-mysql-server 开发自己的mysql server
- CF 768B
- JavaScript高级程序编程(二)
- 计蒜客 38228. Max answer-线段树维护单调栈(The Preliminary Contest for ICPC China Nanchang National Invitational I. Max answer 南昌邀请赛网络赛) 2019ICPC南昌邀请赛网络赛
- compass和paoding分词器的基本使用