def verifymail(request): response_json = {} if request.method == 'POST': print(request.POST) for x, y in request.POST.items(): print("key,value", x, ":", y) emailID = str(request.POST.get("emailID")) OTP = int(ranint(7)) message = 'OTP for your account verification is ' + str(OTP) sendMail('OTP For email Verification', message, emailID) stop = datetime.now() + timedelta(minutes=15) stop = str(stop.strftime("%d/%m/%Y %H:%M:%S")) if OTPData.objects.filter(emailID=emailID).exists(): row = OTPData.objects.get(emailID=emailID) setattr(row, 'otp', OTP) setattr(row, 'flag', False) setattr(row, 'stop', stop) row.save() else: OTPData.objects.create(emailID=emailID, otp=OTP, stop=stop) response_json['success'] = True response_json['message'] = 'Successful' else: response_json['success'] = False response_json['message'] = "Not Post Method" print(str(response_json)) return JsonResponse(response_json)
def reset_password(request): response_json = {} if request.method == 'POST': for x, y in request.POST.items(): print("key,value", x, ":", y) ident = str(request.POST.get("ident")) if LoginData.objects.filter(ident=ident).exists(): genpassword(10) row = LoginData.objects.get(ident=ident) setattr(row, 'password', genpassword) row.save() message = 'Password for your account has been successfully reset to ' + genpassword + '. Please be careful in the future.' sendMail('Password Reset', message, ResetData.objects.get(ident=row).emailID) response_json['reset'] = True response_json['resetMessage'] = 'Reset Successful' else: response_json['reset'] = False response_json['resetMessage'] = 'No User with the given data exist' response_json['success'] = True response_json['message'] = 'Successful' else: response_json['success'] = False response_json['message'] = "Not Post Method" print(str(response_json)) return JsonResponse(response_json)
def sendMails(): global start global test print "[*]Thread Mail start.\n" sendMail('[Mail]', 'Security Camera', 'Raspberry pi security camera update', 'img2.jpg') sendMail('[Mail]', 'Security Camera', 'Raspberry pi security camera update', 'img2.jpg') timer(15) test = 0 start = False
def main(): mydb = dbConect() cursor = mydb.cursor() cursor.execute("SELECT ID,Name,URl,XPath,LastPrice,LowestPrice FROM watcher") result = cursor.fetchall() mydb.commit() for entry in result: wID,Name,URL,XPath,LastPrice,LowestPrice = entry[0:5+1]# the +1 is because of the way python handels slice (they are like the walls between the array objects) strValue = request(URL=URL,XPath=XPath) if debug: print("strValue is: ", strValue) strValue = Formating(value=strValue) if debug: print("strValue is: ", strValue) CurrentPrice = toInt(strValue) if debug: print("CurrentPrice is: ", CurrentPrice) if(CurrentPrice < LowestPrice): print("wooohoo new Low point") updateDbPrices(db=mydb,ID=wID,LastPrice=CurrentPrice,LowestPrice=CurrentPrice) subject=config['content']['NewLowPonit']['Title'].format(name=Name,last_price=LastPrice,lowest_price=LowestPrice,current_price=CurrentPrice) msg=config['content']['NewLowPonit']['msg'].format(name=Name,last_price=LastPrice,lowest_price=LowestPrice,current_price=CurrentPrice) sendMail(subject=subject,msg=msg) elif(CurrentPrice < LastPrice): print("not that exiting but stil Cool")# at least in my opinion maybe only sen msg with an option for that case in future updateDbPrices(db=mydb,ID=wID,LastPrice=CurrentPrice,LowestPrice=LowestPrice) subject=config['content']['ItGotCheaper']['Title'].format(name=Name,last_price=LastPrice,lowest_price=LowestPrice,current_price=CurrentPrice) msg=config['content']['ItGotCheaper']['msg'].format(name=Name,last_price=LastPrice,lowest_price=LowestPrice,current_price=CurrentPrice) sendMail(subject=subject,msg=msg) elif(CurrentPrice > LastPrice): print("the price even rows :( ") updateDbPrices(db=mydb,ID=wID,LastPrice=CurrentPrice,LowestPrice=LowestPrice) else: print("no change in the price") if debug: print("CurrentPrice:",CurrentPrice) print("LastPrice:",LastPrice) print("LowestPrice:",LowestPrice) time.sleep(config['sleeptime'])#it also sleeps after the last item ! mydb.disconnect()
def sendReportOCR(request): if request.method == 'POST': for x, y in request.POST.items(): print("key,value", x, ":", y) reportID = str(request.POST.get("reportID")) reportfault = str(request.POST.get("status")) if(reportfault == "True"): message = 'OCR Mismatch for ' + reportID + '. Please verify.' sendMail('OCR Mismatch',message,"*****@*****.**") response_json['success'] = True response_json['message'] = 'Successful' else: response_json['success'] = False response_json['message'] = "Not Post Method" print (str(response_json)) return JsonResponse(response_json)
def forgot_Ident(request): response_json = {} if request.method == 'POST': for x, y in request.POST.items(): print("key,value", x, ":", y) emailID = str(request.POST.get("emailID")) if LoginData.objects.filter(emailID=emailID).exists(): identInstance = ResetData.objects.get(emailID=emailID).ident message = 'Username for your account is ' + identInstance.ident + '. Please be careful in the future.' sendMail('Username', message, emailID) response_json['forgot'] = True response_json['forgotMessage'] = 'EMail Successful' else: response_json['forgot'] = False response_json['resetMessage'] = 'No User with the given data exist' response_json['success'] = True response_json['message'] = 'Successful' else: response_json['success'] = False response_json['message'] = "Not Post Method" print(str(response_json)) return JsonResponse(response_json)
from bs4 import BeautifulSoup import requests from Mail import sendMail from writeAndRead import saveData, checkData data = 0 source = requests.get('https://www.worldometers.info/coronavirus/').text soup = BeautifulSoup(source, 'html.parser') table = soup.find('tbody') i = 3 for row in table.find_all_next(string=True): i = i + 1 if 'Denmark' in row: i = 0 if i == 2: data = row break data = int((str(data).replace(',', ''))) if data > checkData(): print('Sending email') sendMail(data) print('Saving data') saveData(str(data))