コード例 #1
0
def forward(session):
    logger.info(f'=== 岗位:{session.name} ===')
    os.makedirs(config.resume_download_dir, exist_ok=True)
    resumes = resume.history_resume_list(session)
    downloads = filter_newly_download(session, resumes)
    need_sends = list(filter_condition(session, downloads))
    if need_sends:
        m = mail.Email(config.email_sender, config.email_smtp_sever,
                       config.email_sender, config.email_password)
        now = time.strftime("%Y-%m-%d %H:%M", time.localtime())
        title = f'{now} 收到 {session.name} 简历{len(need_sends)}份'
        content = '<table border="1" cellspacing="0">' + \
            '\n'.join([candidate.html()
                       for _, candidate in need_sends]) + '</table>'
        attaches = [file_path for file_path, _, in need_sends]
        m.send(session.email_receivers, title, content, attaches)
        logger.info(title)
    else:
        logger.info('没有收到新的简历')
コード例 #2
0
def sendAlertMail():
    urlBoard = "http://www.moneycontrol.com/stocks/marketinfo/meetings.php?opttopic=brdmeeting"
    urlSplit = "http://www.moneycontrol.com/stocks/marketinfo/splits/index.php"
    today = date.today()
    eid, pwd = getKeys()
    """------------
    scrap url split
    ------------"""
    alertSplit = scrap.stockAlert(urlSplit)
    alertSplit.collect()
    m, p = alertSplit.scrapSplit()
    """------------
    scrap meeting
    ------------"""
    alertBoard = scrap.stockAlert(urlBoard)
    alertBoard.collect()
    alertBoard.scrapEvents()
    d = alertBoard.getTmrQtly()
    """------------
    mailing part
    ------------"""
    smail = mail.Email(eid, pwd, "Stock-Alert", ["emailID"])
    if (d):
        a, b = smail.sendEvent(d, "Quaterly Meeting Tomorrow")
    if (m):
        a, b = smail.sendSplit(m, "Split Today")
    if today.day == 1:
        s = alertBoard.getMonthQtly()
        a, b = smail.sendEvent(s, "Monthly Quaterly Meeting")
        smail.sendMail()
        smail.quit()
        sys.exit()
    if today.weekday() == 6:
        if (p):
            a, b = smail.sendSplit(p, "Weekly Split")
        s = alertBoard.getWeekQtly()
        a, b = smail.sendEvent(s, "Weekly Quaterly Meeting")
    smail.sendMail()
    smail.quit()
コード例 #3
0
def handle_email():
    """Handles Email class from mail.py"""

    email = mail.Email('smtp.office365.com', 587)

    print('Reading contacts...')
    email.get_contacts()

    print('Reading email template...')
    email.read_template()

    # Setup SMTP server and email to all contacts
    print('Setting up SMTP connection')
    data = get_config()
    email_address = data['address']
    password = data['password']
    email.setup_smtp_server(email_address, password)
    email.send_email_to_each_contact(email_address=email_address,
                                     email_subject='COVID-19 Screening',
                                     image_path=get_filename())

    print('Email(s) Sent!')
コード例 #4
0
def send(digest_file, config_file='config.ini'):
    for f in (digest_file, config_file):
        if not os.path.isfile(f):
            raise FileNotFoundError(f)

    log_file = os.path.join('logs', digest_file + '.log')
    os.makedirs(os.path.dirname(log_file), exist_ok=True)
    logging.basicConfig(filename=log_file, level=logging.INFO,
                        format='%(asctime)s - [%(created)d] - %(levelname)s - %(message)s')

    config_parser = configparser.ConfigParser()
    config_parser.read(config_file)
    user = config_parser['user']

    user_email = user['email']
    user_key = user['key']

    digest_data = read_digest_file(digest_file)
    with mail.login(user_email, user_key) as connection:
        print(f'Successfully logged in to {user_email}')
        for idx, item in enumerate(digest_data):
            print(f'Sending email {idx+1}/{len(digest_data)}', end='...')
            recipient_email = item['params']['email']

            email = mail.Email(connection,
                               sender=user_email, receiver=recipient_email,
                               subject=item['subject'],
                               body=item['body'])

            level, response = email.send()

            print('success' if level == 0 else 'failed')
            if level == 0:
                logging.info(response)
            elif level == 1:
                logging.warning(response)
            elif level == 2:
                logging.error(response)
コード例 #5
0
 def __to_email__(row):
     return mail.Email(msgid=uuid.UUID(row["UUID"]),
                       receiver=row["Receiver"],
                       subject=row["Subject"],
                       body=row["Body"])
コード例 #6
0
# send mail
import smtplib
import mail
port = 587
host = "smtp-mail.outlook.com"
password = "******"
username = "******"
to_list = ["*****@*****.**"]
message = """From: from email <*****@*****.**>
To: Vasu Vanka <*****@*****.**>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

mailer = mail.Email(host=host, port=port, username=username, password=password)

mailer.connect()
mailer.send(to=to_list, text=message)
mailer.disconnect()
コード例 #7
0
        return text

    def go_to_amd(self):
        gpus_elem = self.driver.find_element_by_xpath(
            "html/body/div/main/div[1]/div[1]/ol/li[4]/a/span")
        gpus_elem.click()

        amd_gpus_elem = self.driver.find_element_by_xpath(
            "html/body/div/main/div[1]/div[4]/div[2]/h2/a")
        amd_gpus_elem.click()
        time.sleep(2)


#Create class instances
if __name__ == '__main__':
    scraper = Scraper()
    email = mail.Email()

import os

replacements = {"-": "", " ": "", ":": "", ".": ""}
today = str(scraper.replace(str(datetime.date.today()), replacements))
day_before_yesterday = str(int(today) - 2)

#Remove file from day before yesterday because we don't need it anymore
try:
    os.remove(day_before_yesterday + "products.csv")

except FileNotFoundError:
    print("File doesn't exist!")
コード例 #8
0
ファイル: core.py プロジェクト: Ilyin-V-V/nfs_quota
				while index < index_max:
					if index < index_off:
						quota = quota_arr[index].split(', ')
						user,use,soft,hard = quota[3],quota[4],quota[5],quota[6]
						u_use,u_soft = re.findall(r"'(.*)'",use),re.findall(r"'(.*)'",soft)
						u_use,u_soft = u_use[0],u_soft[0]
						if (long(u_use) > long(u_soft)):
							if soft != "'0'":
								obj_log.loglogged("Warning usage quota exceeded"+' '+user+' '+use+' '+soft+' '+hard)
								user_login = re.findall(r"'(.*)'",user)
								use_user = re.findall(r"'(.*)'",use)
								use_soft = re.findall(r"'(.*)'",soft)
								use_hard = re.findall(r"'(.*)'",hard)
								to_user = user_login[0]+'@'+obj_conf.domain
								obj_mail = mail.Email(obj_conf.host,obj_conf.user,obj_conf.password,
                							obj_conf.m_subject,obj_conf.m_from,to_user,obj_conf.m_text,obj_conf.m_email,
									user_login[0],float(use_user[0])/1000000,float(use_soft[0])/1000000,
									float(use_hard[0])/1000000)
								obj_mail.send_email(user_login[0])
								sleep(5)
					index+=1
                	else:
                        	obj_log.loglogged('SSH workers not available')
                        	success,code='False','SSH workers not available'
                        	code=[success,code]
                        	print code
			exit()
		#QuotaCheck
                if sys.argv[1] == "--check":
                        str_param = ' >> /home/edquota/WorkerQuota/log.log &'
			command_out = obj_scripts.ssh_connect_command(obj_conf.ssh_host,obj_conf.ssh_port,obj_conf.ssh_root,
                        obj_conf.command_quotacheck,str_param)