#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()

最新文章

  1. Git异常:fatal: could not create work tree dir 'XXX': No such file or directory
  2. 十种MYSQL显错注入原理讲解(二)
  3. C#设计模式-外观模式
  4. canvas画布在主流浏览器中的尺寸限制
  5. hdu 1249 三角形
  6. kd tree学习笔记 (最近邻域查询)
  7. R正则表达式的问题
  8. UVa 297 (四分树 递归) Quadtrees
  9. 【pm2】
  10. Jquery学习笔记:删除节点的操作
  11. Spring定时任务解决博客缓存数据更新问题
  12. c# Activex开发之HelloWorld
  13. (转)SimpleDateFormat使用详解
  14. Appium (win7系统)环境搭建----完整版
  15. 移动WEB 响应式设计 @media总结
  16. Unity3D - Animator Controller循环依赖
  17. windows系统下安装node
  18. Shell从入门到精通进阶之四:流程控制
  19. 通过maven profile 打包指定环境配置
  20. Azure IoT 技术研究系列2-设备注册到Azure IoT Hub

热门文章

  1. zookeeper 的 docker 镜像使用
  2. Appache Flume 中文介绍(转)
  3. 【深入ASP.NET原理系列】--Asp.Net Mvc和Asp.Net WebForm实际上共用一套ASP.NET请求管道
  4. springboot(二)
  5. hasura skor 一个pg 的event trigger 扩展
  6. 使用go-mysql-server 开发自己的mysql server
  7. CF 768B
  8. JavaScript高级程序编程(二)
  9. 计蒜客 38228. Max answer-线段树维护单调栈(The Preliminary Contest for ICPC China Nanchang National Invitational I. Max answer 南昌邀请赛网络赛) 2019ICPC南昌邀请赛网络赛
  10. compass和paoding分词器的基本使用