def process_file(self, inputfile, outputdir, filename): rename = str(filename).replace('.csv', '.txt') output_file = outputdir + "/" + rename failed = True csv_file = open(inputfile, 'r') csv_file1 = open(inputfile, 'r') input_file = csv.reader(csv_file, delimiter=',') input_file1 = csv.reader(csv_file1, delimiter=',') validator = Validator() header_problems = validator.header_validator(input_file1) value = len(header_problems) self.log.info("header validation completed with " + str(value) + " problems") if value != 0: write_problems(header_problems, open(output_file, 'w')) Mail().send_mail(rename, output_file) return failed else: data_problems = validator.data_validator(input_file) value = len(data_problems) self.log.info("data validation completed with " + str(value) + " problems") if value != 0: write_problems(data_problems, open(output_file, 'w')) Mail().send_mail(rename, output_file) return failed return False
def main(): db = DBMS.DBMS() mail = Mail.Mail() while True: print("\n\n\n\n\n") multi = -1 while multi < 0 or multi > 5: multi = eval( input("0. Exit.\n" "1. Update from Database.\n" "2. Update from Form.\n" "3. Check Memberships.\n" "4. Display.\n" "5. Send Mails")) if multi == 1: db.update_from_db() elif multi == 2: db.update_from_form() elif multi == 3: db.membership() elif multi == 4: choice = -1 while choice != 2 and choice != 1: choice = eval(input("\n1. Individual.\n2. Group.")) db.membership(choice) elif multi == 5: mail.send_mail() else: return
def new_user_login(self): name = input("Your name:") last_name = input("Your last name:") while True: user_name = input("Your user name:") user1 = Datum().user_name(user_name) if user1: print("Such a username already exists..") else: break while True: password = input( "Your password must be at least 6 digits.\nYour password:"******"Your password is short") else: break while True: mail = input("Your mail:") user1 = Datum().user_mail(mail) if user1: print("Such a mail already exists..") else: break balance = input("Your balance:") new_user = User(name, last_name, user_name, password, mail, balance) Datum().user_login(new_user) time.sleep(2) Mail.Mail().user(new_user.user_name) time.sleep(2) print("Privilege welcome to shopping {} :)".format(new_user.name))
def sayfaKontrol(self): try: elem = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='mainTabView:gidisSeferTablosu:1:j_idt109:0:somVagonTipiGidis1_label']"))) if elem != "": for row in range(1, 15): try: if self.time == self.driver.find_element_by_xpath('/html/body/div[3]/div[2]/div/div/div/div/form/div[1]/div/div[1]/div/div/div/div[1]/div/div/div/table/tbody/tr[{0}]/td[1]/span'.format(row)).text: message=self.driver.find_element_by_xpath('//*[@id="mainTabView:gidisSeferTablosu:{0}:j_idt109:0:somVagonTipiGidis1_label"]'.format(row - 1)).text if message[22] != '0': Mail.Mail(self.email, message).sendMail() print(message) return "successful" else: print("Aradığınız seferde boş yer yok...") self.driver.quit() return except: print ("Saatinizde hata var...") self.driver.quit() sys.exit() else: print("Aradığınız seferde boş yer yoktur...") except (TimeoutException,NoSuchElementException) as ex: print ("TCDD sitesi yüklemede bir hata meydana geldi... Tekrar deneniyor...") self.driver.quit() except UnexpectedAlertPresentException as ex1: print("Güzergah bilgilerinde hata meydana geldi. Kontrol ederek tekrar deneyiniz. İstasyonları doğru girdiğinizden emin olunuz") self.driver.quit() exit()
def main(): # detects if settings.ini is present and creates one if not create_config = Config.Config() config_path = 'settings.ini' if not os.path.exists(config_path): create_config.create_config(config_path) config = ConfigParser.ConfigParser() config.read(config_path) # ---------------------Variables under this line----------------------------------- user_name = config.get('UserInfo', 'username') mail_sender = config.get('UserInfo', 'usermail') mail_recipient = config.get('MailRecipient', 'recipient') text = 'input something here later' filename = 'weeknumber.xlsx' mail_tester = Mail.Mail() workbook = ExcelDoc.ExcelDoc() # -------------------Main loop under this line---------------------------------------- workbook.fill_excel_doc(config_path, filename)
def __init__(self, user, url, sameUser=False): threading.Thread.__init__(self) self.user = user self.sso = Login_sso.Login_sso(url) self.mail = Mail.Mail(url) self.sameUser = sameUser self.message = 'OK'
def submit(self): if tk.messagebox.askyesno("Confirm Submit" , "Are you sure you want to submit? Once submitted , it cannot be undone."): load = Loading() body="Open Palm Service Mail" ml = mail.Mail("<Receiver Mail>", body , "<sender mail>[email protected]" , "<The password>") #Enter the password of the email address or else it will give error if ml.send_mail(): tk.messagebox.showinfo("Done" , "Mail Send") else: tk.messagebox.showinfo("Failed" , "Failed to send the mail. Check your internet connection or call your admin")
def add_order(): ensure_admin() data = json.loads(request.stream.read()) db = DataAccessOrders() or_handler = OrderHandler(db) order = Order(data["date"], data["time"], data["name"], data["telefon"], data["email"], data["location"], data["eventType"], data["note"]) mail = Mail() mail.send_mail(order) return jsonify(or_handler.add_new_order(order))
def buildTestInfo(self, directoryPath, givenClass): listOfWords = [] wordFreqDict = {} files = list(os.walk(directoryPath))[0][2] for file in files: filePath = directoryPath + "/" + file with open(filePath, encoding='utf-8', errors="ignore") as mailFile: listOfWords = helper.getWords(mailFile.read()) wordFreqDict = helper.getWordFreq(listOfWords) self.totTestSetInfo[file] = m.Mail(listOfWords, wordFreqDict, givenClass)
def announce(self, game, subject, message): if game.tester or 'SOLITAIRE' in game.rules: return groups = [game.map.notify] if not host.observers: pass elif type(host.observers) is list: groups += [host.observers] else: groups += [[host.observers]] groups += [x.address for x in [game.gm] + game.powers if x.address] for addresses in groups: if not addresses: continue mail = Mail.Mail(', '.join(addresses), subject, ('', game.gameDir + '/mail')[host.copy], host.dpjudge, '') mail.write(message) mail.close()
def buildTrainingInfoWOStopWords(self, directoryPath, givenClass, stopPath): listOfWords = [] wordFreqDict = {} #print(stopPath) stopWords = helper.readStopWords(stopPath) files = list(os.walk(directoryPath))[0][2] for file in files: filePath = directoryPath + "/" + file with open(filePath, encoding='utf-8', errors="ignore") as mailFile: listOfWords = helper.getWordsSansStopWords( mailFile.read(), stopWords) wordFreqDict = helper.getWordFreq(listOfWords) self.totTrainingSetInfo[file] = m.Mail(listOfWords, wordFreqDict, givenClass)
def read_mail(self, path: str): subject: str = "" body: str = "" with open(path, encoding="utf8") as file: subject = file.readline().replace("Subject: ", "") file.readline() body = file.readline() subject_words = subject.replace("\n", "").split(" ") body_words = body.replace("\n", "").split(" ") subject_words = map( int, subject_words) if (subject_words[0] != "") else [0] body_words = map(int, body_words) if (body_words[0] != "") else [0] return Mail(path, subject_words, body_words)
def submit(self): """This method generates a prompt whenever the user clicks the submit button""" if tk.messagebox.askyesno( "Confirm Submit", "Are you sure you want to submit? Once submitted , it cannot be undone." ): # noqa E501 body = "Open Palm Service Mail" # Enter the password of the email address ml = mail.Mail("", body, "", "") if ml.send_mail(): tk.messagebox.showinfo("Done", "Mail Send") else: tk.messagebox.showinfo( "Failed", "Failed to send the mail. Check your internet connection or call your admin" ) # noqa E501
def list(self, email, subject=''): import Mail results = '' subject = ('DPjudge openings list (%s)' % host.dpjudgeID, 'RE: ' + subject)[subject != ''] for gameName in self.listGames('waiting') + self.listGames('forming'): if 'unlisted' not in self.dict[gameName]: try: game = self.load(gameName) if not game.private: results += game.shortList() except: pass mail = Mail.Mail(email, subject, mailAs=host.openingsAddress) mail.write((':: Judge: %s\n:: URL: %s%s\n\n' % (host.dpjudgeID, host.dpjudgeURL, '/index.cgi' * (os.name == 'nt'))) + (results or 'No Openings!')) mail.close()
def sayfa_kontrol(driver): try: elem = WebDriverWait(driver, 10).until( EC.visibility_of_element_located(( By.XPATH, "//*[@id='mainTabView:gidisSeferTablosu:1:j_idt108:0:somVagonTipiGidis1_label']" ))) if elem != "": sayi = driver.find_element_by_css_selector( '#mainTabView\:gidisSeferTablosu\:1\:j_idt108\:0\:somVagonTipiGidis1_label' ) if sayi.text[22] != '0': mail = Mail.Mail("*****@*****.**", "Yer boşaldı " + sayi.text) mail.sendMail() print(sayi.text) exit() else: print("Yer Yok") driver.quit() except TimeoutException as ex: driver_get(driver)
def __init__(self, file): """ :param file: path to file containing data; a row in file is of format: target_value(0 or 1) mail_content """ # correspondence dict between word and mails # key - word; value - array of mails containing the word self.word_corresp = {} self.MAILS = [] # load the mails into Mail objects, along with their target result with open(file, 'r') as f: for line in f: mail_instance = Mail(line.replace('\n', '')) for word in mail_instance.words: if self.word_corresp.has_key(word): self.word_corresp[word].add(mail_instance) else: self.word_corresp[word] = set([mail_instance]) self.MAILS += [mail_instance] # remove the words which appear in fewer than 30 mails for word, mails in self.word_corresp.items(): if len(mails) < 30: self.word_corresp.pop(word) # a sorted array will help with branch prediction, faster processing sorted_words = sorted(self.word_corresp) # create feature vectors for mails for mail in self.MAILS: # multiplying a bool with an int -> int # faster than int(bool) mail.feature_vector = [(word in mail.words) * 1 for word in sorted_words] self.weights_no = len(sorted_words)
# -*- coding: UTF-8 -*- import re import itchat import requests from itchat.content import ATTACHMENT, TEXT import Monitor import Mail mail = Mail.Mail() #以下是监控微信聊天文件的转发 @itchat.msg_register([ATTACHMENT], isFriendChat=True, isGroupChat=True) def download_files_and_forward(msg): msg.download(msg.fileName) r = re.match('(@@)(.*)', msg['FromUserName']) if r: MessageSource = '群聊' mail.SendMailFile( msg.fileName, MessageSource, msg['ActualNickName'] + '(' + itchat.search_chatrooms(userName=msg['FromUserName'])['NickName'] + ')', msg['FileSize'], msg['CreateTime']) else: MessageSource = '个人' mail.SendMailFile( msg.fileName, MessageSource, itchat.search_friends(userName=msg['FromUserName'])['NickName'] + '(' + itchat.search_friends(userName=msg['FromUserName'])['RemarkName'] + ')', msg['FileSize'], msg['CreateTime'])
# Kibana->dashboard->share->permalink->short url ile alınan url bilgileri aşağıdaki dizine eklenir. # Verilen dashboard sayısı kadar gider ss alır mail atar short_screenshots=['http://kibana:5601/goto/bf63aebefc4cb85f3a85b23ec6207141'] # short_screenshots elemanı kadar rapor alır ve mail atar for i in range(len(short_screenshots)): try: chrome = ChromeSettings.ChromeSettings(chromedriver_path) driver = chrome.settingChrome() kibanaLogin = KibanaLoginPage.KibanaLoginPage(driver) driver = kibanaLogin.loginPage() screenShot=ScreenShotPage.ScreenShotPage(driver,short_screenshots[i]) name=screenShot.screenShotPage() image_name=screenShot.screenShotSave(name) mail = Mail.Mail(image_name) mail.sendMail() except: print ("Main.py for döngüsünde hata meydana geldi...")
operation = input("The action you will take:") if operation == "1": Users.Datum().new_user_login() break elif operation == "2": user = Users.Datum().user_control() if user == 1: Admin.Admin().admin_control() else: print( "******************\nTo view product prices '1'\nFor buy '2'\nTo exit 'q' \nPress....\n******************" ) b = input("Enter value:") if b == "1": Products.Datum().Products_info() break elif b == "2": Sales.Sales(user.user_name) elif b == "q": print("Goodbye") break else: print("Invalid transaction....") elif operation == "3": Mail.Mail().password_control() break elif operation == "q": print("Goodbye") break else: print("Invalid transaction....")
from flask import Flask from import Mail,Message #pip install Flask-Mail # allow less secure app for gmail https://myaccount.google.com/lesssecureapps app =Flask(__name__) mail=Mail(app) app.config['MAIL_SERVER']='smtp.gmail.com' app.config['MAIL_PORT'] = 465 app.config['MAIL_USERNAME'] = '******' app.config['MAIL_PASSWORD'] = '******' app.config['MAIL_USE_TLS'] = False app.config['MAIL_USE_SSL'] = True mail = Mail(app) @app.route("/") def index(): msg = Message('Hello', sender = '*****@*****.**', recipients = ['*****@*****.**']) msg.body = "Hello Flask message sent from Flask-Mail" mail.send(msg) return "Sent" if __name__ == '__main__': app.run(debug = True)
from Mail import * import configparser import sys import os cf = configparser.ConfigParser() cf.read("mail.conf") mail_sender = cf.items("Email") m = Mail(mail_sender[0][1], mail_sender[1][1], mail_sender[2][1], mail_sender[3][1], mail_sender[4][1]) #邮件发送信息设置 to = input("To:") mail_tolist = [] mail_tolist.append(to) cc = input("Cc:") cc_tolist = [] subject = input("Subject:") #邮件主体部分设置 body = "" print("Body:") while True: temp = input() if temp == "": break body += temp.replace("\t", " ") + "\n" if len(sys.argv) <= 1: # 默认不带参数,发送不带附件的邮件
def recieveMail(self): #setter, notify boxholder he/she has mail, fill mailbox temporarily print( "-----------------------------------------------------------------" ) print(" Recieve Mail") print( "-----------------------------------------------------------------" ) print() print(" Please enter mail list file: ") print() mfilename = input(" ") try: raw_mfile = open(mfilename) mail_list = raw_mfile.readlines() for line in mail_list: if line[0] == "#": pass else: mail_list = line.split() if len(mail_list) == 2: recipient = mail_list[0] contents = mail_list[1] mail = Mail(recipient, contents) if recipient in self._boxholders: boxholder = self._boxholders[recipient] box = boxholder.returnBox() box.addMail(mail) print() print( " A {} has been added to {}'s box, Box {:d}." .format(contents, recipient, boxholder.mailbox())) print() except FileNotFoundError: print() print(" ERROR: File not found.") print() prompt = input( " Press 1 to try again or any other key to exit.") if prompt == "1": self.recieveMail() else: return
except: print("Main(" + str(sys._getframe().f_lineno) + ") : Market(", i_market, ")_Error") # Sim is class of Calculate profit Sim = Simulation(market1, market_List, "USDT", base_money) try: log.writeCalculation(Sim.result_sim1) log.writeCoinSorting(Sim.result_coinSorting) except: print("log Err") print("\n===================================\n") if Sim.result_sim1['profit'] >= profit: # Mail to your address mail_subect = "Profit : " + str( Sim.result_sim1['profit']) + " ( " + str( Sim.result_sim1['details']['FirstEx']) + " / " + str( Sim.result_sim1['details']['SecondEx']) + " )" mail_message = Sim.result_sim1['market2'] + " : " + Sim.result_sim1[ 'currency_first'] + "-" + Sim.result_sim1[ 'firstCoin'] + "-" + Sim.result_sim1[ 'currency_second'] + "-" + Sim.result_sim1[ 'secondCoin'] + "-" + Sim.result_sim1[ 'currency_third'] profitMail = Mail(mail_subect, mail_ID, mail_PW, mail_message) i = i + 1 if i > 10: break
import smtplib import Mail class Email: def __init__(self, server, username, password): self.username = username self.server = smtplib.SMTP(server, 587) self.server.ehlo() self.server.starttls() self.server.login(self.username, password) def send(self, email: Mail): self.server.sendmail(self.username, email.to, email.mail) if __name__ == '__main__': email = Mail('*****@*****.**', '*****@*****.**', 'Hey how are you!', 'Hello there :)') gmail = Email('smtp.gmail.com', '*****@*****.**', 'password123') gmail.send(email)