def DetectViolence(): violenceDetector = ViolenceDetector() videoReader = cv2.VideoCapture( "rtsp://*****:*****@118.70.125.33:8554/CH001.sdp") count = 0 while (True): listOfForwardTime = [] isCurrentFrameValid, currentImage = videoReader.read() # print(isCurrentFrameValid) netInput = ImageUtils.ConvertImageFrom_CV_to_NetInput(currentImage) startDetectTime = time.time() isFighting = violenceDetector.Detect(netInput) print(isFighting) endDetectTime = time.time() listOfForwardTime.append(endDetectTime - startDetectTime) targetSize = deploySettings.DISPLAY_IMAGE_SIZE - 2 * deploySettings.BORDER_SIZE currentImage = cv2.resize(currentImage, (targetSize, targetSize)) if isFighting: count += 1 if count == 5: print("saving...") cv2.imwrite('image.jpg', currentImage) # luu image #send mail sendEmail.sendMail( '*****@*****.**', '12345Aa@', '*****@*****.**', 'Fighting', 'Have Fight', 'C:/Users/anlan/OneDrive/Desktop/Project_Violence/ViolenceDetection-master_main/image.jpg' ) resultImage = cv2.copyMakeBorder( currentImage, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, cv2.BORDER_CONSTANT, value=deploySettings.FIGHT_BORDER_COLOR) # copyMakeBorder them borfer cho video else: if count > 5: count = 0 resultImage = cv2.copyMakeBorder( currentImage, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, deploySettings.BORDER_SIZE, cv2.BORDER_CONSTANT, value=deploySettings.NO_FIGHT_BORDER_COLOR) cv2.imshow("Violence Detection", resultImage) print("count", count) userResponse = cv2.waitKey(1) if userResponse == ord('q'): videoReader.release() cv2.destroyAllWindows() break else: isCurrentFrameValid, currentImage = videoReader.read() averagedForwardTime = np.mean(listOfForwardTime)
def main(): denydict = get_ssh_info() for ip, refuselist in denydict.items(): print ip print refuselist refusehtml = refuseToHtml(denydict) print refusehtml title = ['服务器地址', '用户IP', '时间'] lasthour = datetime.now() - timedelta(hours=1) filename = 'xls/ssh_refused_' + lasthour.strftime('%Y-%m-%d-%H') + '.xlsx' writeToExcel(title, denydict, filename) sendMail('ssh拒绝登录信息', refusehtml, sendto, serverinfo, filename)
def DetectViolence(PATH_FILE_NAME_OF_SOURCE_VIDEO, PATH_FILE_NAME_TO_SAVE_RESULT): violenceDetector = ViolenceDetector() videoReader = cv2.VideoCapture(PATH_FILE_NAME_OF_SOURCE_VIDEO) print(videoReader) shouldSaveResult = (PATH_FILE_NAME_TO_SAVE_RESULT != None) if shouldSaveResult: videoSavor = VideoSavor(PATH_FILE_NAME_TO_SAVE_RESULT + "_Result", videoReader) listOfForwardTime = [] isCurrentFrameValid, currentImage = videoReader.read() count = 0 while isCurrentFrameValid: print(isCurrentFrameValid) netInput = ImageUtils.ConvertImageFrom_CV_to_NetInput(currentImage) startDetectTime = time.time() isFighting = violenceDetector.Detect(netInput) print(isFighting) endDetectTime = time.time() listOfForwardTime.append(endDetectTime - startDetectTime) targetSize = deploySettings.DISPLAY_IMAGE_SIZE - 2*deploySettings.BORDER_SIZE currentImage = cv2.resize(currentImage, (targetSize, targetSize)) if isFighting: count += 1 if count == 5: print("saving...") cv2.imwrite('image.jpg',currentImage) resultImage = cv2.copyMakeBorder(currentImage,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,cv2.BORDER_CONSTANT,value=deploySettings.FIGHT_BORDER_COLOR) else: resultImage = cv2.copyMakeBorder(currentImage,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,deploySettings.BORDER_SIZE,cv2.BORDER_CONSTANT,value=deploySettings.NO_FIGHT_BORDER_COLOR) cv2.imshow("Violence Detection", resultImage) print("count",count) if shouldSaveResult: print("shouldSaveResult",shouldSaveResult) videoSavor.AppendFrame(resultImage) userResponse = cv2.waitKey(1) if userResponse == ord('q'): videoReader.release() cv2.destroyAllWindows() break else: isCurrentFrameValid, currentImage = videoReader.read() # cv2.imshow('image',image) # PrintUnsmoothedResults(violenceDetector.unsmoothedResults) averagedForwardTime = np.mean(listOfForwardTime) if count > 5: print("truee") sendEmail.sendMail('*****@*****.**','12345Aa@','*****@*****.**','Fighting','Have Fight','C:/Users/anlan/OneDrive/Desktop/Project_Violence/ViolenceDetection-master_main/image.jpg')
import sendEmail import commands print 'Running complete tttt analysis' print "############################################" print "############################################" print "############################################" print "######## ELECTRON #######" print "######## CHANNEL #######" print "############################################" print "############################################" print "############################################" os.system('rm log') os.system('cp FourTop_EventSelection_El.cc FourTop_EventSelection_El.cc.back') sendEmail.sendMail("Update from the fourtophawk","Starting full analysis run") ######################################################################## ####### Run ScaleDown systematic ###### ######################################################################## #edit alg to switch bool for i, line in enumerate(fileinput.input('FourTop_EventSelection_El.cc', inplace=1)): sys.stdout.write(line.replace('int doScaleShift = 0;', 'int doScaleShift = 1;')) #compile os.system('g++ -g -L ~/lib -I ../../ -l TopTreeAnaContent53 -l TopTreeAna53 -l MLP -l TreePlayer -l TMVA -l XMLIO -I `root-config --incdir` `root-config --libs` FourTop_EventSelection_El.cc -o EL') #run os.system('./EL > log')
htmlPage = BeautifulSoup(page.content, 'html.parser') productTitle = htmlPage.find("h1", class_="pr-new-br").getText() price = htmlPage.find("span", class_="prc-slg").getText() image = htmlPage.find("img", class_="ph-gl-img") convertedPrice = float(price.replace( ',', '.', ).replace(' TL', '')) if (convertedPrice <= 550): print("Ürünün fiyatı düştü. Fırsatı Kaçırma...") htmlEmailContent = """\ <html> <head></head> <body> <h3>{0}</h3> <br/> {1} <br/> <p>Ürün linki: {2}</p> </body> </html> """.format(productTitle, image, url) # toMail, message and htmlContent sendMail("*****@*****.**", "Ürünün fiyatı düştü. Fırsatı Kaçırma...", htmlEmailContent)
def main(argv): global host global user global passwd global dbname global unix_socket global serverinfo global sendto db = FuckDb(host, user, passwd, dbname, unix_socket) IPlist = [] with open('iplist.txt', 'rt') as f: for ip in f.readlines(): ip = ip.strip('\n') if ip: IPlist.append(ip) #db.create_db() if argv[1] == "-u": print "update db info" if len(argv) > 2: setdate = datetime.strptime(argv[2], '%Y-%m-%d') db.add_info(IPlist, setdate) else: db.add_info(IPlist) elif argv[1] == "-d": print "send domain info" domainlist = db.get_domain() domainhtml = domainToHtml(domainlist) print domainhtml yestday = datetime.now() - timedelta(days=1) title = ["主机", "域名", "创建时间"] filename = 'xls/DOMAIN_INFO_' + yestday.strftime('%Y_%m_%d') + '.xlsx' writeToExcel(title, domainlist, filename) sendMail( yestday.strftime('%Y-%m-%d') + "域名信息", domainhtml, sendto, serverinfo, filename) elif argv[1] == "-di": print " domain change info" deldomain = db.get_deldomain() if len(deldomain) == 0: print "There is no delete domain info" html = "" else: print "delete domain is:" print deldomain html = infoToHtml(deldomain, "del") newdomain = db.get_newdomain() if len(newdomain) == 0: print "There is no new domain" else: print "new domain is:" print newdomain html += infoToHtml(newdomain, "new") if len(html) < 10: html = "昨日无域名修改信息" yestday = datetime.now() - timedelta(days=1) sendMail( yestday.strftime('%Y-%m-%d') + "域名信息", html, sendto, serverinfo) else: print '-d:发送domain信息(全部)' print '-u:昨天日志信息入库' print '-di:显示昨天删除或增加域名信息' return 0
import sendEmail sendEmail.sendMail('aragh yeah')
#!/usr/bin/env python print "Content-Type: text/html" print from sendEmail import sendMail sendMail("wokeup Sleep_Recording","") print "<h1>wokeup Email Successfully Sent</h1>"
def main(argv): global diskitems global groupname global zurl global zuser global zpasswd global sendto global serverinfo yestday = datetime.today() - timedelta(days=1) yestday = datetime.strptime(yestday.strftime('%Y-%m-%d') + ' 00:00:00','%Y-%m-%d %H:%M:%S') yestday = time.mktime(yestday.timetuple()) today = datetime.strptime(datetime.today().strftime('%Y-%m-%d' + ' 00:00:00'),'%Y-%m-%d %H:%M:%S') today = time.mktime(today.timetuple()) print '查询范围:' + str(yestday) + ' - ' + str(today) zapi = ZabbixAPI(url = zurl, user = zuser, password=zpasswd) #获取Storage Servers主机组id grouplist = zapi.do_request('hostgroup.get',{'filter':{'name':groupname}}) groupids = [] for groupinfo in grouplist['result']: groupids.append(groupinfo['groupid']) print groupids #指定组id,屏蔽一些host,mysql之类的主机 hostlist = zapi.do_request('host.get',{'groupids':groupids, 'output':['hostid','host'], 'status':1}) hostlist = hostlist['result'] hostdict = {} #for host in hostlist: # hostdict[host['host']] = host['hostid'] # print hostdict olddiskinfo = get_disk_history(zapi,hostlist,yestday) newdiskinfo = get_disk_history(zapi,hostlist,today) print olddiskinfo print newdiskinfo diskusage = {} for host in hostlist: print str(host['host']) ip = host['host'] diskusage[ip] = [] print olddiskinfo[ip] iteminfo = [] for itemid in olddiskinfo[ip].keys(): path = diskitems[itemid] free = int(newdiskinfo[ip][itemid]) usage = int(olddiskinfo[ip][itemid]) - free filter = {'name':['Free inodes on $1 (percentage)'], 'key_':'vfs.fs.inode[' + path+ ',pfree]'} ifree = get_item_history(zapi,host['hostid'],path,today,filter,type=0) filter = {'name':['Total disk space on $1'], 'key_':'vfs.fs.size[' + path + ',total]'} disktotal = get_item_history(zapi,host['hostid'],path,today,filter,type=3) iteminfo.append({'path':path,'usage':usage,'free':free,'inode':ifree,'total':int(disktotal)}) diskusage[ip] = iteminfo print diskusage """ diskusage数据类型{ip:['path':'/','usage':1234,'free':1111,'inode':99, 'path':'/data1','usage':1234,'free':1111,'inode':99], ip2:[]} """ yestday = datetime.today() - timedelta(days=1) htmlinfo = infoToHtml(diskusage) title = ['服务器地址','目录','总空间','剩余空间','日使用量','inodes百分比'] filename = 'xls/disk_usage' + yestday.strftime('%Y-%m-%d') + '.xlsx' writeToExcel(title,diskusage,filename) sendMail(yestday.strftime('%Y-%m-%d') + "磁盘空间信息", htmlinfo, sendto, serverinfo,filename) return 0
def email(request): return HttpResponse( json.dumps( sendEmail.sendMail(request.POST["user"], request.POST["content"])))
#!/usr/bin/env python print "Content-Type: text/html" print from sendEmail import sendMail sendMail("leftHosue Sleep_Recording","") print "<h1>leftHosue Email Successfully Sent</h1>"
#!/usr/bin/env python print "Content-Type: text/html" print from sendEmail import sendMail sendMail("alarm Sleep_Recording","") print "<h1>alarm Email Successfully Sent</h1>"
#!/usr/bin/env python print "Content-Type: text/html" print from sendEmail import sendMail sendMail("toSleep Sleep_Recording","") print "<h1>toSleep Email Successfully Sent</h1>"