def reslut_record(op_status,data_ip,vip): if op_status==0: log('host %s Cluster information abnormal' % data_ip) subject='cluster information abnormal,vip %s' % vip body='vip:%s,data_ip:%s,this is Cluster information abnormal,please check cluster information' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) elif op_status==1: log('keepalived is restart success,host is %s' % data_ip) subject='cluster keepalived is restart success,vip:%s' % vip body='vip:%s,data_ip:%s,this is cluster keepalived is restart success' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) elif op_status==2: log('slave %s exec system command failed' % data_ip) subject='slave %s exec system command failed' % data_ip body='vip:%s,data_ip:%s,slave exec system command failed,pleases check slave exec log' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) elif op_status==3: log('master %s exec system command failed' % data_ip) subject='master %s exec system command failed' % data_ip body='vip:%s,data_ip:%s,master exec system command failed,pleases check master exec log' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) elif op_status==4: log('VIP is %s,master is %s,waitting slave the exec result timeout,read result information in the redis' % (vip,data_ip)) subject='waitting slave the exec result timeout,vip:%s' % vip body='VIP is %s,master is %s,waitting slave the exec result timeout,read result information in the redis' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body)
def send_comment_mail(para_dic): print "send photo start." print para_dic #fullText = create_attachment(data, receivers) fullText = create_attachment(para_dic['data'], para_dic['text'], para_dic['receivers'], para_dic['photoname'], para_dic['subject'], para_dic['sender']) #sendmail(fullText, receivers) sendmail(fullText, para_dic['receivers'], para_dic['sender'], para_dic['smtpaddr'], para_dic['username'], para_dic['passwd']) print "send photo over.OK"
def user(self): userid = int(self.e.get()) msg = data_retrive(userid) messagebox.showinfo("DataBase Snippet", msg) sendmail() messagebox.showinfo( "mail sent acknowledgment", "we done it! \n every mail over there are identified and accnowledgment was sent" )
def SendMail(report): cmd = ['hostname'] p = sub.Popen(cmd,stdout=sub.PIPE,stderr=sub.PIPE) out,err = p.communicate() if err != "": print err sys.exit() Subject = "Some new vistors in %s"%out Body = "Here is the report:\n%s"%report send.sendmail(ToAddr,Subject,Body)
def get_storage_info(folder, quota, server_name, users): # command cmd = 'du -hs '+folder #run command output = subprocess.check_output(cmd, shell=True) # parse the output result_list = output.decode("utf-8").split() # calculate output size and unit from command output res = re.compile("([0-9]+)([a-zA-Z]+)") total_size_output = res.match(result_list[0]) try: # if the output of command in the format ex. "20G" size_output = int(total_size_output.group(1)) unit_output = total_size_output.group(2).strip() except: # if the output of command in the format ex. "20.2G" split_by_dot = result_list[0].split('.') size_output = int(split_by_dot[0]) unit_output = split_by_dot[1][-1] # calculate input size and unit from json data total_size_input = res.match(quota) size_input = int(total_size_input.group(1)) unit_input = total_size_input.group(2).strip() # message and subject strings in order to send notification to the user subject = "ALERT | Storage Quota Exceeded | On "+server_name+" Server | "+folder msg = '''You have exceeded the user storage quota: Folder: {} Server Name: {} Your Quota: {} Your Current Folder Size: {}B'''.format(folder, server_name, quota, str(size_output)+unit_output) # condition to check if input and output folder size have the same units if ((unit_output == "M") and (unit_input[0] == "M")) or ((unit_output == "G") and (unit_input[0] == "G")): if (size_output > size_input): print("Quota Exceeded") sendmail(users, subject, msg) # condition to check if input and output folder size have different units elif (unit_output == "G") and (unit_input[0] == "M"): size_output = size_output * 1024 if (size_output > size_input): print("Quota Exceeded") sendmail(users, subject, msg)
def contact(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): cd = form.cleaned_data print cd['subject'],cd['message'],cd['email'] sendmail( cd['email'], cd['subject'] , cd['message']) # send_mail( # cd['subject'], # cd['message'], # cd.get('email', '*****@*****.**'), # ['*****@*****.**'], # ) return HttpResponseRedirect('/contact/thanks/') else: form = ContactForm() return render(request,'contact_form.html', {'form': form})
def submit(): if request.method == 'POST': customer = request.form['customer'] dealer = request.form['dealer'] model = request.form['model'] rating = request.form['rating'] comments = request.form['comments'] if customer == '' or dealer == '' or model == '': return render_template('index.html', message='Please, enter required fields') if db.session.query(Feedback).filter( Feedback.customer == customer).count() == 0: data = Feedback(customer, dealer, model, rating, comments) db.session.add(data) db.session.commit() sendmail(customer, dealer, model, rating, comments) return render_template('success.html') return render_template('index.html', message='You have already submitted feedback.')
def deposit(Net_balance, address): clear = ('cls' if os.name == 'nt' else 'clear') global net_balance print(":: Deposit ::") try: deposit_amount = input("Enter Amount In Rupees: ") #Check for negetive values if float(deposit_amount) >= 0.0: #check for extra large amount #limits amount towards power of e if (len(deposit_amount) > 14) or ( (len(str(float(deposit_amount) + net_balance))) > 14): os.system(clear) print(':: Amount Limit Exceeded! ::') return #Deposit amount is incremented in counter else: net_balance += float(deposit_amount) os.system(clear) MSG = "You Have Successfully Depositted An Amount Of Rs " + str( deposit_amount ) + "\n\nYour Net Account Balance is Rs " + str(net_balance) msg = sendmail(address, MSG) os.system(clear) if not (msg == True): print(msg) print(":: You Have Successfully Depositted An Amount Of Rs", deposit_amount, "::", '\n') return elif float(deposit_amount) < 0.0: os.system(clear) #If user inputs negetive amount print(":: Please Enter Right Amount! ::\n") return deposit(net_balance, address) else: os.system(clear) print(":: Please Enter Right Amount! ::\n") return deposit(net_balance, address) except ValueError: os.system(clear) print(":: Please Enter Right Amount! ::\n") return deposit(net_balance, address)
def withdraw(Net_balance, address): clear = ('cls' if os.name == 'nt' else 'clear') global net_balance print(":: Withdraw ::") #If amount is zero returns to atm function if float(net_balance) <= 0.0: print(":: Withdrawl Impossible! ::\n:: Your Account Balance = Rs", net_balance, "::", "\n:: Please Deposit Amount First! ::\n") return else: try: with_draw = input("Enter Amount In Rupees: ") os.system(clear) #If user inputs negetive amount if float(with_draw) < 0.0: os.system(clear) print(":: Please Enter Right Amount! ::\n") return withdraw(net_balance, address) #Checks if amount in withdraw is less than amount in counter elif float(with_draw) <= net_balance: net_balance -= float(with_draw) MSG = "You Have Successfully Withdrawn An Amount Of Rs " + str( with_draw) + "\n\nYour Net Account Balance is Rs " + str( net_balance) msg = sendmail(address, MSG) os.system(clear) if not (msg == True): print(msg) print(":: You Have Successfully Withdrawn An Amount Of Rs", with_draw, "::", '\n') return else: os.system(clear) print( ":: Withdrawl Impossible! ::\n:: Your Acount Balance = Rs", net_balance, "::", "\n") return withdraw(net_balance, address) except ValueError: os.system(clear) print(":: Please Enter Right Amount! ::\n") return withdraw(net_balance, address)
def change_pin(Pin, address): clear = ('cls' if os.name == 'nt' else 'clear') os.system(clear) pin_count = 0 print(":: Create Your Own Pin....::") while pin_count != 3: print(":: Entries left :", (3 - pin_count), "::") pin = str(gp("Enter 4-Digit Pin : ")) os.system(clear) if (len(pin) == 4) and (pin.isdigit() == True): if not pin == Pin: os.system(clear) confirm_pin = str(gp("Confirm Pin : ")) if pin == confirm_pin: Pin = pin os.system(clear) MSG = "You Have Successfully Changed Your Pin" msg = sendmail(address, MSG) os.system(clear) if not (msg == True): print(msg) print(':: Pin Changed Successfully! ::\n') return (Pin) else: os.system(clear) print(":: Pin Change Unsuccessful! ::") print(":: Your Pin Did Not Match! ::\n") pin_count += 1 else: pin_count += 1 os.system(clear) print(":: Pin Change Unsuccessful! ::") print(":: Please Enter A New Pin ::\n") else: pin_count += 1 os.system(clear) print(":: Pin Change Unsuccessful! ::") print(":: Invalid Pin! ::\n") return (Pin)
def new_account(): clear = ('cls' if os.name == 'nt' else 'clear') import time, datetime filename = join() user_name1 = input("New Account\nEnter First Name : ") os.system(clear) user_name2 = input("Enter Last Name : ") if (user_name1.isalpha() == False) or (user_name2.isalpha() == False) or (user_name1 == user_name2): os.system(clear) print("Invalid Name!") return new_account() #auto-generated pin auto_gen_pin = rd.randint(1000, 9999) os.system(clear) full_name = (user_name1.lower()) + ' ' + (user_name2.lower()) acc_no = account_no_gen(full_name) conf = code() Mail_address = input("Please Enter A Valid Email Address : ") if not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", Mail_address): os.system(clear) confirm_mail = "None" print("____INVALID-MAIL-ADDRESS____") else: MSG = "Confirming mail address!" + "\n\n" + "Account Number : " + acc_no + "\n\nYour Verification Code Is : '" + conf + "'" confirm_mail = sendmail(Mail_address, MSG, "Confirmation Mail") if (confirm_mail == True): os.system(clear) print("Verification Code Has Been Sent To Your Email Address!") conf_code = input("Enter Provided Code : ") if (conf_code.lower() == conf.lower()): confirm_mail = Mail_address os.system(clear) print("Email Address Verified!\n") else: os.system(clear) print( "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n" ) confirm_mail = "None" else: os.system(clear) print(confirm_mail, '\n') confirm_mail = "None" print("Your Auto-Generated Pin : ", auto_gen_pin) confirm = input("Want To Use This Pin ? \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system(clear) print("Account Name :", user_name1 + ' ' + user_name2, "\nAccount Number :", acc_no, "\nPin :", auto_gen_pin) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system(clear) with open(filename, "a+") as wr: #rot13() function is called for encoding enc = rot13(full_name) new = [ acc_no, enc, auto_gen_pin, '0.0', time.strftime('%d-%b-%Y at %I:%M %p'), confirm_mail ] w = csv.writer(wr) w.writerow(new) wr.close() MSG = "Dear " + str( full_name.upper() ) + "!\n\tWelcome To YOB(YOUR OWN BANK) Service. Your account is successfully created. \n\tThanks for putting your trust on our service. \n\n\nFor any queries, feel free to contact our 24 hours costumer service at: [email protected]" vr = sendmail(Mail_address, MSG) os.system(clear) if not (vr == True): print(vr) print("Account Created Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system(clear) print("Account Not Created!") return login_user() else: os.system(clear) print("Account Not Created!") return new_account() else: os.system(clear) pin_count = 0 print("Create Your Own Pin....") while pin_count != 3: print("Entries left :", (3 - pin_count)) pin = str(gp("Enter 4-Digit Pin : ")) os.system(clear) if (len(pin) == 4) and (pin.isdigit() == True): os.system(clear) confirm_pin = str(gp("Confirm Pin : ")) if pin == confirm_pin: os.system(clear) print("Account Name :", user_name1 + ' ' + user_name2, "\nAccount Number :", acc_no, "\nPin :", pin) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system(clear) with open(filename, "a+") as wr: #rot13() function is called for encoding enc = rot13(full_name) new = [ acc_no, enc, pin, '0.0', time.strftime('%d-%b-%Y at %I:%M %p'), confirm_mail ] w = csv.writer(wr) w.writerow(new) wr.close() MSG = "Dear " + str( full_name.upper() ) + "!\n\tWelcome To YOB(YOUR OWN BANK) Service. Your account is successfully created. \n\tThanks for putting your trust on our service. \n\n\nFor any queries, feel free to contact our 24 hours costumer service at: [email protected]" vr = sendmail(Mail_address, MSG) os.system(clear) if not (vr == True): print(vr) print("Account Created Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system(clear) print("Account Not Created!") return login_user() else: os.system(clear) print("Account Not Created!") return new_account() else: print("Your Pin Did Not Match!") pin_count += 1 else: pin_count = pin_count os.system(clear) print("Invalid Pin!") os.system(clear) print("Account Not Created!") return login_user()
def capture(): face_locations = [] face_encodings = [] face_names = [] process_this_frame = True count = 0 flag = 0 name = "Unknown" while True: # Grab a single frame of video ret, frame = video_capture.read() bw = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) face_cascade = cv2.CascadeClassifier( "haarcascade_frontalface_default.xml") faces = face_cascade.detectMultiScale(bw, 1.3, 5) crop_img = [] for x, y, w, h in faces: cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 3) crop_img = frame[y:y + h, x:x + w] cv2.imwrite("detected_face/temp.png", crop_img) # image = face_recognition.load_image_file("detected_face/temp.png") # Resize frame of video to 1/4 size for faster face recognition processing small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses) rgb_small_frame = small_frame[:, :, ::-1] # Only process every other frame of video to save time #if process_this_frame: # Find all the faces and face encodings in the current frame of video face_locations = face_recognition.face_locations(rgb_small_frame) face_encodings = face_recognition.face_encodings( rgb_small_frame, face_locations) #face_encoding = face_recognition.face_encodings(image) face_names = [] for face_encoding in face_encodings: try: # See if the face is a match for the known face(s) matches = face_recognition.compare_faces( known_face_encodings, face_encoding) #name = "Unknown" face_distances = face_recognition.face_distance( known_face_encodings, face_encoding) best_match_index = np.argmin(face_distances) if matches[best_match_index]: name = known_face_names[best_match_index] else: name = "Unknown" #face_names.append(name) except ValueError: pass cv2.imshow("performing_face_Detection", frame) k = cv2.waitKey(33) if name == "Unknown": count = count + 1 if count == 10: video_capture.release() cv2.destroyAllWindows() sendmail() #giving user some time to reply for server print('giving user an 30 seconds time to reply for mail') for i in range(1, 31): print('#' * i, i) time.sleep(1) #time.sleep(60) ans = receivemail() if ans == 'A' or ans == 'a': print('Authority replied "ALLOW" opening the lock now') time.sleep(1) os.system('python3 lock.py') #print('1') flag = 1 break elif ans == None: flag = 1 print("Authority doesn't replied\nLOCK WILL NOT OPEN") else: print( 'Authority replied "DENY" lock will not be opened') flag = 1 break else: continue elif name != "Unknown": os.system('python3 lock.py') #print('2') print(name) flag = 1 break os.remove("detected_face/temp.png") cv2.imshow("performing_face_Detection", frame) if cv2.waitKey(25) & 0xFF == ord('q'): break if flag == 1: break #os.remove("faces/temp.png") #process_this_frame = not process_this_frame # Release handle to the webcam video_capture.release() cv2.destroyAllWindows()
def fun_main(data_ip,vip): #判断VIP挂载情况 status=vip_operation.update_vip_mount_info(vip,data_ip) # if status==0: # subject='this is key:"vip_info:%s is not exists' % vip # body='this is key:"vip_info:%s is not exists,host data_ip is %s' % (vip,data_ip) # sendmail('*****@*****.**','*****@*****.**',subject,body) # redis_op.set('vip_info:%s' % vip,pickle.dumps({})) # record_log.log('please check data in the redis,beacause this is key:"vip_info:%s" is not exists' % vip) # sys.exit(1) if status==2: subject='warings:vip mount information faile,%s' % vip body='vip:%s,data_ip:%s,vip check failed' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) #redis_op.set('vip_info:%s' % vip,pickle.dumps({})) record_log.log('warings----vip mount information faile,host data_ip %s,vip %s' % (data_ip,vip)) sys.exit(1) #取得是否脑裂的状态,当前这个VIP的KEY,还有VIP在每个节点上的挂载状态 try: status,vip_info_key,vip_status=vip_operation.vip_health_check(vip) except Exception as e: record_log(e) #判断当前主机是否正在被处理中,如果是,则程序全部退出,know_problems alarm_host_list=redis_op.get('know_problems_host') if alarm_host_list: alarm_host_list=pickle.loads(alarm_host_list) if data_ip in alarm_host_list: record_log.log('host %s is exists know_problems,skip this check' % data_ip) sys.exit(1) #如果脑裂 if status==2: #检查VIP是否已经无法ping通 status=vip_operation.check_trouble_vip(vip) #如果VIP网络连通性正常 if not status: #发邮件报警 #db_connect.redis_op.set('vip_info:%s' % vip,pickle.dumps({})) subject='this is cluster split-brain,vip:%s' % vip body='vip:%s,data_ip:%s,this is cluster split-brain,please check cluster status' % (vip,data_ip) sendmail('*****@*****.**','*****@*****.**',subject,body) #如果已经无法ping通 else: try: lock_key_rw(data_ip,'know_problems_host') op_status=vip_operation.mysql_role_restart_keepalived(data_ip,vip) record_log.reslut_record(op_status,data_ip,vip) except Exception as e: record_log.log(e) #如果没有脑裂 elif status==1: status=vip_operation.check_trouble_vip(vip) if not status: record_log.log('VIP is %s,cluster state is normal' % (vip)) else: try: lock_key_rw(data_ip,'know_problems_host') op_status=vip_operation.mysql_role_restart_keepalived(data_ip,vip) record_log.reslut_record(op_status,data_ip,vip) except Exception as e: record_log.log(e) elif status==0: print 'this is a alerm,send information admin mobile' key='check_vip_inum:%s' % vip lock_key_rw(1,key) check_inum=redis_op.get(key) if len(check_inum==2): #db_connect.redis_op.set('vip_info:%s' % vip,pickle.dumps({})) redis_op.redis_delete(key) else: sys.exit(0) return 1
from send_mail import sendmail from config import sms_info import threading import queue if __name__ == '__main__': q = queue.Queue() b = FuncQueue(flag=1, q=q) t_list = [] fhandler = open('./mechine.conf', 'r') for line in fhandler: t = threading.Thread(target=b.listqueue, args=(line, )) t.start() t_list.append(t) fhandler.close() for j in t_list: j.join() qlist = [q.get() for i in range(q.qsize())] # alert sms email stat_str = (' '.join(qlist)) if len(qlist) > 0: # 邮件告警 sendmail(' '.join(qlist)) # 短信告警 # stat_str = stat_str.replace('\n', '') # sendTemplateSMS(sms_info[0], (stat_str, 'server down'), '185595')
print(product_name) #print(product_id) url2 = f"https://www.supremenewyork.com/shop/{product_id}.json" product_detail = requests.get(url2) product_page = json.loads(product_detail.content) #print(product_page) for product in product_page['styles']: if product['name'] == 'Purple': for item in product['sizes']: if item['name'] == 'Small' and item[ 'stock_level'] == 1: print(item['name']) print(item['stock_level']) return True return False keyword = input("Input the keyword, seperate with ',' ::").lower() #keyword = "Quilted" keylist = keyword.split(",") for keyword in keylist: if (search(keyword)): sendmail()
def atm(user_name, Net_balance, Pin, History, acc_no, address): filename = join() clear = ('cls' if os.name == 'nt' else 'clear') #input for change of pin # new_pin_opt = input("Change Pin : \n1. Yes \n2. No \n") # os.system(clear) # if (new_pin_opt == '1') or (new_pin_opt.lower().startswith('y')): import time, datetime print(time.strftime('Date:%d-%b-%Y \nTime:%I:%M %p Today:%A\n')) print(""" Y Y 000 BBBBBB Y Y 00 00 B B Y Y 00 00 B B Y 00 00 BBBBBB Y 00 00 B B Y 00 00 B B Y 000 BBBBBB """) print(("DEAR"), (user_name.upper()) + ("!")) print("WELCOME TO YOB SERVICE \n") #User input for selection global net_balance net_balance += Net_balance Opr = input( ":: Please Select An Option Provided Below : \n1. Check Account Balance \n2. Check Acount Number \n3. Deposit \n4. Withdraw \n5. Transfer Amount \n6. Last Acive Session \n7. Change Pin \n8. Change/Verify Mail Address \n0. Exit \n" ) os.system(clear) if not Opr.isdigit(): Opr = 9 while int(Opr) != 0: if int(Opr) == 1: os.system(clear) print(":: Your Acount Balance = Rs", "{:,} ::".format(net_balance), "\n") elif int(Opr) == 2: os.system(clear) print(":: Your Account Number =", acc_no, ":: \n") #Deposit function is called elif int(Opr) == 3: os.system(clear) deposit(net_balance, address) #Withdraw function is called elif int(Opr) == 4: os.system(clear) withdraw(net_balance, address) #Amount Transfer function is called elif int(Opr) == 5: os.system(clear) if net_balance < 0.0: print( ":: Amount Can Not Be Transferred! ::\n:: Your Acount Balance = Rs", balance, "::", "\n") else: account_no = input('Enter 12-Digit Account Number : ') if (account_no == acc_no): os.system(clear) print(":: Amount Transfer Not Possible! ::") print(":: Provided Account Number Is Yours! ::\n") else: amount = amount_transfer(account_no, net_balance, acc_no, address) net_balance -= float(amount) elif int(Opr) == 6: os.system(clear) print(":: Your Acount Was Previously Logged in on", History, "::", "\n") #Change Pin function is called elif int(Opr) == 7: os.system(clear) Pin = change_pin(Pin, address) elif int(Opr) == 8: os.system(clear) Mail_address = input(":: Please Enter A Valid Email Address : ") conf = code() MSG = "Confirming Mail Address.\n\nAccount Number : " + acc_no + "\n\nYour Verification Code Is : '" + conf + "'" if Mail_address == address: os.system(clear) print( ":: Your Email Address Is Verified! ::\n:: Want To Change Your Address ?" ) opt = input("1. Yes\n2. No \n") os.system(clear) if opt.lower().startswith("y") or opt == '1': Mail_address = input( ":: Please Enter A New Valid Email Address : ") if Mail_address == address: os.system(clear) print(":: Email Address Already Verified! ::") else: verify = sendmail(Mail_address, MSG, "Confirmation Mail") if (verify == True): os.system(clear) print( "Verification Code Has Been Sent To Your Email Address!" ) user_conf = input("Enter Provided Code : ") if (user_conf.lower() == conf.lower()): address = Mail_address os.system(clear) print( "Email Address Verified And Changed Successfully!\n" ) else: os.system(clear) print( "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n" ) else: os.system(clear) print(verify) else: print(":: Email Address Unchanged! ::") else: os.system(clear) verify = sendmail(Mail_address, MSG, "Confirmation Mail") if (verify == True): os.system(clear) print( "Verification Code Has Been Sent To Your Email Address!" ) user_conf = input("Enter Provided Code : ") if (user_conf.lower() == conf.lower()): address = Mail_address os.system(clear) print( "Email Address Verified And Changed Successfully\n" ) else: os.system(clear) print( "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n" ) else: os.system(clear) print(verify) else: os.system(clear) print(":: Invalid Selection! ::") #Incase above condition(s) get meet #Loop continues untill '0' is entered Opr = input( ":: Please Select An Option Provided Below : \n1. Check Account Balance \n2. Check Acount Number \n3. Deposit \n4. Withdraw \n5. Transfer Amount \n6. Last Acive Session \n7. Change Pin \n8. Change/Verify Mail Address \n0. Exit \n" ) if not Opr.isdigit(): Opr = 9 os.system(clear) os.system(clear) print( "::: Thanks For Using ATM! :::\n::: We Hope You Are Satisfied With Our Service. :::\n::: Have A Nice Day Ahead. :::" ) print("About:") with open('About.txt', 'r') as infile: show = infile.read() print(show) with open(filename, 'a+') as ap: #rot13() function is called for encoding enc = rot13(user_name.lower()) re_new = [ acc_no, enc, str(Pin), str(net_balance), time.strftime('%d-%b-%Y at %I:%M %p'), address ] w = csv.writer(ap) w.writerow(re_new) ap.close() return
def __init__(self): self.mysql = sql_class.SqlConnect() self.sendmail = send_mail.sendmail()
import unittest from HTMLTestRunner import HTMLTestRunner import time import send_mail test_dir = "./test_case/" discover = unittest.defaultTestLoader.discover(test_dir,pattern="test*.py",top_level_dir=None) if __name__ == "__main__": now = time.strftime("%Y-%m-%d %H_%M") filename = "./report/" + '/' + now + "result.html" fp = open(filename,'wb') runner = HTMLTestRunner(stream=fp,title="测试报告",description="用例情况:",verbosity=2) runner.run(discover) fp.close() send_mail.sendmail("*****@*****.**")
def amount_transfer(account_no, balance, acc_no, address): import time, datetime clear = ('cls' if os.name == 'nt' else 'clear') os.system(clear) d = data() filename = join() amount = 0.0 print(":: Amount Transfer ::") Inactive_account = str('#' + account_no) if Inactive_account in d.keys(): os.system(clear) print(":: Provided Account Number Is Not Active! ::") return amount elif account_no in d.keys(): try: amount = input("Enter Amount In Rupees: ") if float(amount) < 0.0 or ('-' in amount): os.system(clear) print(":: Please Enter Right Amount! ::\n") return amount_transfer(account_no, balance, acc_no, address) elif float(amount) > float(balance): os.system(clear) print( ":: Amount Can Not Be Transferred! ::\n:: Your Acount Balance = Rs", balance, "::", "\n") return amount_transfer(account_no, balance, acc_no, address) else: os.system(clear) print(":: Account Number :", account_no, "::") print(":: Name :", d[account_no][0], "::") print(":: Amount Transfer = Rs", "{:,} ::".format(float(amount)), "\n") confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): with open(filename, 'a+') as ap: #rot13() function is called for encoding enc = rot13(d[account_no][0]) current_balance = balance balance = str(float(d[account_no][2]) + float(amount)) Message = str( "Amount of 'Rs " + str(amount) + "' was received on " + str(time.strftime('%d-%b-%Y at %I:%M %p')) + ", through Account Number: " + str(acc_no)) re_new = [ account_no, enc, d[account_no][1], balance, d[account_no][3], d[account_no][4], Message ] w = csv.writer(ap) w.writerow(re_new) ap.close() os.system(clear) MSG_from = "You Have Successfully Transferred An Amount Of Rs " + str( amount) + " To A/C #" + str( account_no ) + "\n\nYour Net Account Balance Is Rs " + str( float(current_balance) - float(amount)) MSG_to = "You Have Received An Amount Of Rs " + str( amount) + " From A/C #" + str( acc_no ) + "\n\nYour Net Account Balance Is Rs " + str( float(balance)) sendmail(address, MSG_from) msg2 = sendmail(d[account_no][4], MSG_to) os.system(clear) if not (msg2 == True): print(msg2) print(":: Amount Transferred Successfully! ::") return amount else: amount = 0 os.system(clear) print(":: Amount Transfer Unsuccessful! ::") return amount except ValueError as err: os.system(clear) print("Error :", err) print(":: Please Enter Right Amount! ::\n") return amount_transfer(account_no, balance, acc_no, address) else: os.system(clear) print(":: No Match Found! ::") return amount
def sendmail(): send_mail.sendmail()