class Database(object): _timestamp_format = "%Y%m%d_%H%M" _filename_pattern = "tmp/tvu-mitglieder_%s.csv" _linkname = "tmp/tvu-mitglieder.csv" def __init__(self): self._email = Email() @property def email(self): return self._email def load(self, update=True, username=None, password=None): if update: data = get_mitglieder_csv(username, password) self._save(data) self._email.parse(self._linkname) def _save(self, data): time_stamp = datetime.now().strftime(self._timestamp_format) filename = self._filename_pattern % time_stamp f = open(filename, "w") f.write(data) f.close() if os.path.exists(self._linkname): os.unlink(self._linkname) os.symlink(os.path.basename(filename), self._linkname)
def sendalert(alerts, attachments=[], is_all_fail=False): email = Email() emails = ONE_FAIL_NOTIFICATIONS['emails'] if is_all_fail: emails = ALL_FAIL_NOTIFICATIONS['emails'] p = subprocess.Popen(['hostname'], stdout=subprocess.PIPE) hostname = p.stdout.read() report = StringIO() for x in alerts: print x report.writelines([x, '\r\n\r\n']); body = report.getvalue() report.close() subject = '[WARN] At least one tested failed - %s - %s' % (hostname, time.ctime()) if is_all_fail: subject = '[SERVE] All TEST FAILED for a service - %s - %s' % (hostname, time.ctime()) email.sender = 'Gagein <*****@*****.**>' retries = 3 while retries > 0: try: email.send(emails, subject, body, '', attachments) retries = 0 except Exception, ex: retries = retries - 1 print '... Retry due to exception: ', ex
def sendalert(alerts, attachments=[], is_all_fail=False): email = Email() emails = ONE_FAIL_NOTIFICATIONS['emails'] if is_all_fail: emails = ALL_FAIL_NOTIFICATIONS['emails'] p = subprocess.Popen(['hostname'], stdout=subprocess.PIPE) hostname = p.stdout.read() report = StringIO() for x in alerts: print x report.writelines([x, '\r\n\r\n']) body = report.getvalue() report.close() subject = '[WARN] At least one tested failed - %s - %s' % (hostname, time.ctime()) if is_all_fail: subject = '[SERVE] All TEST FAILED for a service - %s - %s' % ( hostname, time.ctime()) email.sender = 'Gagein <*****@*****.**>' retries = 3 while retries > 0: try: email.send(emails, subject, body, '', attachments) retries = 0 except Exception, ex: retries = retries - 1 print '... Retry due to exception: ', ex
def dispatch_email(self, email_context): try: subject = self.email['email_subject'].format( socket.gethostname(), time.strftime('%d-%m-%Y:%H:%M')) email = Email(self.email_config, subject, email_context) email.mail() except KeyError as error: error = "Error to create email! Variable not found: ".format( socket.gethostname()) + str(error)
def dispatch_email(self, email_context): try: subject = self.email['email_subject'].format( socket.gethostname(), time.strftime('%d-%m-%Y:%H:%M')) email = Email(self.email_config, subject, email_context) email.mail() except KeyError as error: error = "Error to create email! Variable not found: ".format( socket.gethostname()) + str(error)
def sendalert(alerts, hostname, attachments=[]): email = Email() report = StringIO() report.writelines(['\t\t Server Performance Alert [%s]\r\n' % hostname, '\r\n\r\n']) for x in alerts[1:]: print x report.writelines([x, '\r\n\r\n']); body = report.getvalue() report.close() subject = 'Server Performance Alert [%s] [%s] - %s' % (alerts[0], hostname, time.ctime()) email.sender = 'Gagein <*****@*****.**>' email.send(emails, subject, body, '', attachments)
def add_email(self): """ 添加账号 """ try: while True: lastname = input("请输入姓氏: ") if lastname != '': break print("\t\t输入不能为空!!!") while True: firstname = input("请输入名字: ") if firstname != '': break print("\t\t输入不能为空!!!") while True: # 判断department是否合法 department = input("请输入部门[sales, development, accounting](无部门输入no): ") if department in ["sales", "development", "accounting", "no"]: break print("\t不存在此部门,请重新输入!!!") while True: company = input("请输入公司: ") if company != '': break print("\t\t输入不能为空!!!") department = None if department == 'no' else department # 如果没有部门归属,返回None,否则正常返回 email = Email(firstname, lastname, department, company) # 调用邮箱类,创建邮箱对象 self.email_containers.append(email) print("\t\t添加成功!!!\t\t") except Exception as e: print(f"添加账号函数错误:{e}")
def handle(self, *args, **options): subject = 'Tareas por vencer!' for user in get_logged_out_users(): print(user.username) deadlines = [] for category in user.category_set.all(): for task in category.task_set.all(): if (task.notify_user and not task.complete and is_deadline_near(task.deadline)): deadlines.append(task) for subtask in task.subtask_set.all(): if (subtask.notify_user and not subtask.complete and is_deadline_near(subtask.deadline)): deadlines.append(subtask) if len(deadlines) > 0: message = '' message += 'Gracias por usar GST!\n' message += 'Usted tiene {} tareas por vencer:\n\n'.format(len(deadlines)) for deadline in deadlines: message += '\t+ Tarea: {} - Vence: {}'.format(str(deadline.name), deadline.deadline.strftime( '%Y-%m-%d %H:%M:%S %z')) Email().send(user.email, subject, message)
def testEmail(self): archivo = open('Emails.csv') reader = csv.reader(archivo, delimiter=',') for fila in reader: lista = fila[0].split('@') unEmail = Email(lista[0], lista[1], lista[2]) self.agregarEmail(unEmail)
def sendalert(alerts, hostname, attachments=[]): email = Email() report = StringIO() report.writelines( ['\t\t Server Performance Alert [%s]\r\n' % hostname, '\r\n\r\n']) for x in alerts[1:]: print x report.writelines([x, '\r\n\r\n']) body = report.getvalue() report.close() subject = 'Server Performance Alert [%s] [%s] - %s' % (alerts[0], hostname, time.ctime()) email.sender = 'Gagein <*****@*****.**>' email.send(emails, subject, body, '', attachments)
def get_pending_email(self, email_key): uri = '/emails/pending' headers = {'X-Email-Key': email_key} try: result_dict = self._rq.request('get', uri, headers=headers) except error.ResourceNotFoundError: return None eml = Email(self._rq, **result_dict) return eml
def read_email_dir(word_encoding_dictionary, path, label): emails = [] for email_fname in os.listdir(os.path.join(DATA_DIR, path)): email_path = os.path.join(path, email_fname) email = Email.read(path=email_path, word_encoding_dictionary=word_encoding_dictionary, label=label) emails.append(email) return emails
def main(): data = Experiment() data.retrieve_data() emails = [] for example in data.raw_data_set: emails.append(Email(example[1])) i = 1 with open("dates.csv", "w") as dates_file: for email in emails: dates_file.write(str(i) + "," + str(email.get_hour()) + "\n")
def listWriteAndSend(driver, csvFile, body, subject=''): reader = csv.DictReader(csvFile) loopNumber = 1 for row in reader: print('Sending E-mail number {}...'.format(loopNumber)) parsedBody = body.format(row['Name']) to = row['Email'] email = Email(parsedBody, subject, to) writeAndSend(driver, email) #Sleep up to 45 secs loopNumber += 1 time.sleep(random.choice([30, 37, 45]))
def all_transformers(): return [ Email(), SMS(), FBMsg(), Phone(), BankWire(), Paypal(), DebitCard(), ContactlessCard(), Tube(), FBStatus(), Tweet(), ]
def get_emails(user_folder_uri): """ Returns a list of all the emails inside the given user folder """ emails = [] for classification_folder in os.listdir(user_folder_uri): for root, dirs, files in os.walk( os.path.join(user_folder_uri, classification_folder)): for f in files: email_uri = os.path.join(user_folder_uri, classification_folder, f) email = Email(email_uri) emails.append(email) return emails
def emailTest(): #### VARIABLES #### valid = False # boolean to determine if a response is valid answer = "" # string to store user response new = False # boolean to for User __init__ parameter sender = "" # string to store email address of user recipient = "" # string to store recipient address print("\nWelcome to Blue Sky Corporation Email Service \n") # INPUT - Ask if user is new. while valid == False: answer = input("Are you a new user? y/n") if answer == "y" or answer == "Y": new = True valid = True elif answer == "n" or answer == "N": new = False valid = True else: print("Invalid input") # Pass boolean response to initialize User object if new == True: user = User(True) else: user = User(False) # PROCESS - Assign sender and INPUT recipient # Check for validity of sender and recipient email addresses sender = user._emailAddress valid = False while valid == False: if "@" in sender and "." in sender and sender.find( "@") + 1 < sender.find("."): valid = True else: sender = input( "Please enter your email address. Must be in valid email format.\n" ) valid = False while valid == False: recipient = input("Please enter recipient email address: ") if "@" in recipient and "." in recipient and recipient.find( "@") + 1 < recipient.find("."): valid = True else: print("Please enter a valid email address format.\n") # Create and print email object email = Email(sender, recipient) # OUTPUT email.printEmail() email.toString()
def check(self, directory): files = os.listdir(directory) hostname = config['main']['hostname'] list_names = [] for file in files: name = re.findall(r'dump\-\d+\-\d+\-\d+T\d+:\d+:\d+', str(file)) if name: list_names.append(str(name)) list_names.sort() last_file = list_names[len(list_names) - 1] result = re.search(r'\d+\-\d+\-\d+T\d+:\d+:\d+', str(last_file)) a = str(result.group(0)) timestamp_last_file = time.mktime( datetime.datetime.strptime(a, "%Y-%m-%dT%H:%M:%S").timetuple()) if (time.time() - timestamp_last_file) > int( config['dump']['time_for_alerting_dump']): Telegram().sendMessage("Last dump file in %s ALARM hostname: %s" % (a, hostname)) Email().sendMessage("Last dump file in %s ALARM hostname: %s" % (a, hostname)) return "Last dump file in %s this ALARM" % (a) else: return "Last dump file in %s this OK" % (a)
Column("contact", String(255)), Column("sku_id", String(255)), Column("batch_ref", String(255)), ) orders = Table( "orders", metadata, Column("order_id", Integer, primary_key=True), Column("customer_id", ForeignKey("user.username")), Column("amount", float()), Column("quantity", Integer()), Column("shipperId", Integer()), Column("order_address", String(255)), Column("order_email", Email()), Column("order_date", Date()), Column("order_status", Boolean()), Column("timestamp", datetime()), Column("paymentDate", datetime()), Column("paymentId", Integer, primary_key=True), Column("payentId", ForeignKey("payments.id")), Column("paid", Boolean()), ) orderdetail = Table( "orderdetails", metadata, Column("id_", Integer, primary_key=True), Column("order_id", ForeignKey("orders.id")),
from email import Email from excel import Excel from news import News m_email = Email() m_excel = Excel() m_news = News() news_list = m_news.find_news('키워드!') m_email.from_email = 'al' m_email.to_email = 'dkjs' m_email.subject = 'Dear. ' for news in news_list: m_email.contents = m_email.contents + news + '\n' m_email.send_email() m_excel.excel_file = 'result.xlsx' m_excel.save_to_excel(news_list)
from email import Email from manejador import manejador if __name__=='__main__': print("Ingrese nombre") nombre=input() print("Ingrese su id de cuenta") idCuenta=input() print("Ingrese su dominio") dominio=input() print("Ingrese su tipo de dominio") tipoDominio=input() print("Ingrese su contraseña") contraseña=input() mail=Email(idCuenta,dominio,tipoDominio,contraseña) print("Estimado",nombre,"te enviaremos tus mensajes a la direccion",idCuenta+"@"+dominio+"."+tipoDominio) print("Ingrese su contraseña actual") contraseña=input() if(mail.verificaContraseña(contraseña)): print("Ingrese su nueva contraseña") mail.setContraseña(input()) else: print("Contraseña incorrecta") print(mail.getContraseña()) me = manejador() me.testEmail() dom=input("Ingrese un dominio:") cant=me.buscarEmailsPorDominio(dom) print("Cantidad de emails con ese dominio:",cant)
def __init__(self): self._email = Email()
# def __init__(self, id, name, emails): # self.id = id # self.name = name # self.emails = emails def setemails(self, emails): self.emails = emails # private function, can not be accessed out side of the class. def __somePrivateFunction(self): print('accessing private function') if __name__ == '__main__': print('invoking User main method') user = User('user-id-1234', 'bala') # user.__init__('user-id-1234', 'bala') email1 = Email('*****@*****.**', 'home', False) email2 = Email('*****@*****.**', 'work', True) email3 = Email('*****@*****.**', 'other', False) emails = [email1, email2, email3] user.setemails(emails) print 'user id: ', user.id, ' name: ', user.name for email in user.emails: print 'email: ', email.value, ' type: ', email.type, ' is primary: ', email.primary
from login import login from endSession import endSession from settings import Settings from email import Email from writeAndSend import writeAndSend import time import random from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC body = 'This is the body' subject = 'This is the subject' to = '*****@*****.**' #Creates email to send email = Email(body, subject, to) #Creates a chromedriver session chromedriver_location = Settings.chromedriver_location driver = webdriver.Chrome(chromedriver_location) #Login login(driver, credentials.email, credentials.password) #Write email writeAndSend(driver, email) #Logout endSession(driver)
from messageboard import db, userdb, emaildb from post import Post from user import User from email import Email # # # associate Models to the db Post.set_db(db) User.set_db(userdb) Email.set_db(emaildb)
def rowToEmail(self, row): email = Email(row[0], row[1], row[2], row[3], row[4]) return email
def insert_email(self, email): self.session.add(Email(email[0], email[1], self.session.query(Customer) .filter(Customer.customer_id == email[1]).one())) self.session.commit()