需求:录制的时候,需要点击开始录制,但是出现过同事手一抖,没有录制的现象,所以领导希望我写一个脚本,可以检测下如果没有开始录制,那么发短信报警,如下是脚本,谢谢观看
#!/usr/bin/env python # *-coding:UTF-8-*- import re import os import time import subprocess import json dirs = [] riqi = time.strftime("%Y%m%d",time.localtime(time.time())) date = riqi[4:] shijian = time.strftime("%r",time.localtime(time.time()))[-2:] video = [] text = "" def getDirs(): """get dirs which we should be handle,for example Jsd1606a""" os.chdir("/kejiandata/record") all=os.listdir(".") for dir in all: pattern1 = re.compile("[A-Z][0-9]?[a-z]{1,2}[0-9]{4}a?") pattern2 = re.compile("w[a-z]{3}[0-9]{4}a?") if match1 or match2: dirs.append(dir) return dirs def main(dirs): """get Dirs‘son directory name,for example Jsd1606a/20161014010135""" for Sdir in dirs: os.chdir("/kejiandata/record/"+Sdir) Sdirs = os.listdir(".") zhuanye = Sdir.lower() Flv = [] for videoDir in Sdirs: if videoDir[:8] == riqi: accessTime= time.localtime(os.stat(videoDir).st_atime) Time = time.strftime("%r",accessTime)[-2:] if Time == shijian: Flv.append(videoDir) if not Flv: neirong = zhuanye + date + shijian.lower() + "无" global text text += neirong if text: os.environ["text"] = str(text) subprocess.Popen("java -jar /usr/local/SendMsg.jar ‘18613319610‘ 【达内时代科技】以下班级无 录制视频:$text",shell=True) if __name__ == "__main__": getDirs() print dirs main(dirs)
时间: 2024-10-22 14:21:16