def IRevent(self, number): # if the alarm is 'active', trigger alarm if self.fsm.activeCheck == True: hat.set_pixels(blue) self.label2.config(text='ALARM', background='blue') # send tweet # Program opened from Python 2.7 due to version errors with Tweepy Module cmd = 'python twitterHandling.py' subprocess.Popen(cmd, shell=True) # send email method from sendEmail.py script sendEmail() # Call Picture Taking Method self.after(10, self.takePic) # after 4 seconds, call activate method to revert to active state self.after(2000, self._activate)
def send_email_verification(self, email1, usern): verification_code = random.randint(1000, 9999) subject = "Verification Code" message = f"Verification code <br> <h1>{verification_code}</h1><br>Your username:<h2>{usern}<h2>" email_send = sendEmail(email1, message, subject) send_verification = email_send.send() if send_verification: print("Success:email sent") return verification_code print("Email failed to send") return False
def emailHelper(subject, message, emailType, configFile = None): try: if(configFile == None): configFile = gConfigFile configFile = gInstallDir + "/etc/" + configFile print "\nUsing Config File: %s\n"%(configFile) if not os.path.isfile(configFile): message = "ERROR!!! Cannot read the config file" + configFile + "\n" gConfig = ConfigParser.ConfigParser() gConfig.read(configFile) fromEmail = gConfig.get("emailCommon","from") smtpServer = gConfig.get("emailCommon","smtpServer") if(emailType == "error"): toEmail = '"' + gConfig.get("emailError","to") + '"' elif(emailType == "report"): toEmail = gConfig.get("emailReport","to") print "%s %s %s"%(fromEmail, toEmail, smtpServer) sendEmail(fromEmail, toEmail, subject, message, smtpServer) except: log("ERROR!!! while trying to send the report as an email.\n", True, False)
# objectDetection first there_is_banana_in_image = takePic() if there_is_banana_in_image: model = torch.load("saved_models/new_bananas.pickle") with torch.no_grad(): img = loadBananaImg() input = torch.FloatTensor([img]) output = model.forward(input) _, pred = output.max(dim=1) prediction = pred[0].item() response_cat = bananaResponses[prediction] response = response_cat[random.randint(0, 3)] sendEmail(address2sendEmail2, subject, response) else: sendEmail(address2sendEmail2, subject, "You are out of bananas bro... ") # if objectDetection finds a banana run the pred through the model """ if(True): modPred = 0 sendEmail( address2sendEmail2, subject, bananaResponses[modPred]) # else send email that you are out of nanas else: sendEmail( address2sendEmail2, subject, "You are out of bananas bro... ") """
# author: zhangwudi # 2019/3/15 21:35:37 import schedule import time from sendEmail import * address = input("请输入要发送的邮箱:") send_mail = sendEmail() send_mail.send_email_weibo(address) send_mail.send_email_baidu(address) # 定时每天早上6点发邮件 更多功能请自研究schedule模块 # schedule.every().day.at("6:00").do(send_mail.send_email_weibo(address)) # # while True: # schedule.run_pending() # time.sleep(1)
elif (message[-1] == '-'): pre_element = getPreviousElement(count) count -= 1 current_element = pre_element # moveToElement(current_element) interactElement(current_element) print(current_element_global.get_attribute("class")) sleep(1) else: x = interactWebsite(message) if x == 'quit': interactElement(getNextElement(getCurrentElement())) pattern_list = [] if (SOS_start_time): # pass sendEmail(user) sendWechatMessage(user) # cv2.putText(frame, message, (50, 150), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0,0,255), 2) # if the `q` key was pressed, break from the loop if key == ord("q"): break # do a bit of cleanup cv2.destroyAllWindows() vs.stop()
#接收的ele有可能是None值,有可能有值 self.assertIsNotNone(ele) def test_goods(self): ele = readExcel("goods") #接收的ele有可能是None值,有可能有值 self.assertIsNotNone(ele) #表示测试结束的函数 def tearDown(self): print "test end" #定义一个代码运行的主函数入口 if __name__ == "__main__": #新建一个测试套件来存放所有的测试用例 suite = unittest.TestSuite() #将测试用例一个一个的放入袋子中 suite.addTest(testProject("test_login")) suite.addTest(testProject("test_booking")) suite.addTest(testProject("test_goods")) #定义一个测试报告的文件位置和文件名 file = open("E:/keyword/report.html","wb") #使用测试报告的模块来运行测试套件 r = HTMLTestRunner.HTMLTestRunner(stream=file,title=u"我的测试报告",description=u"测试加法函数是否正确") r.run(suite) #最后关闭测试报告的文件 file.close() sendEmail()
comparedfile = open(compared_date, 'w') compared_CVS = csv.writer(comparedfile) columTitle = [ "Address", "Asking Price", "Assessed Price", "Diff", "Uploaded Date", "New Upload", "Neighbourhood", "Sq Foot", "Building Type", "Basement", "Basement Finish", "Garage", "Year", "zoning", "Full Address", "URL" ] compared_CVS.writerow(columTitle) saveSrappedHouses() query() rows = mycursor.fetchall() compared_count = len(rows) writeCvs(comparedfile, compared_CVS, rows) filenames = [scarpe_data, compared_date] if newAds: newAdsFile = today.strftime("%B %d, %Y New Ad ") + ".csv" newlyUploadedfile = open(newAdsFile, 'w') newlyUploaded_CVS = csv.writer(newlyUploadedfile) newlyUploaded_CVS.writerow(columTitle) newlyUploadedQuery() rows2 = mycursor.fetchall() writeCvs(newlyUploadedfile, newlyUploaded_CVS, rows2) filenames.append(newAdsFile) sendEmail(filenames, scrappedID, newAds, compared_count, main_url)
from setupFiles import * from sendEmail import * from keys import * lookFiles("msg.txt") lookFiles("contacts.txt") print("Enter email's subject:") subject = input() sendEmail(myGmail, myPass, subject)