Example #1
0
def student_summary_line_body(student, grade, cats, pcts, send_email):
    name_col_width = 16
    if send_email:
        salutation = "Hi {},\n\n".format(student.first)
        salutation += "Here's your current estimated grade information: \n\n"
    else:
        salutation = "{}".format(student.name()).ljust(name_col_width)

    grade_info = "Current Est. Grade: {0:.1f} based on: ".format(grade)
    n = len(cats)
    for j in range(n):
        cat = cats[j]
        punct = ', ' if j < n - 1 else '.'
        grade_info += "{0:s} (weighted {1:.0f}%): {2:.1f}%{3:s}" \
                .format(cat.name, cat.pct_of_grade, pcts[j], punct)
    if send_email:
        try:
            g = gmail.Gmail("Current Est. Grade", '')
            signature = g.signature
            g.body = salutation + grade_info + '\n\n' + signature
            print(student.email)
            print(g.body)
            g.recipients = [student.email]
            g.send()
        except:
            print("failed to send the email.  ", \
                    "Perhaps there is something wrong with the signature file.")
    else:
        print(salutation, grade_info)
Example #2
0
def rpt_student_scores(gb, preview=False, send_email=False):
    students = gb.get_actives()
    for student in students:
        text = student_score_text(gb, student)
        if not send_email and not preview:
            print(student.name())
            print(text)
        else:
            salutation = "Hi {},\n\n".format(student.first)
            salutation += "Here are the scores I have recorded for you.  Please let me know if you find any errors: \n\n"
            body = salutation + text
            if preview:
                print(body)
            else:
                try:
                    g = gmail.Gmail("Recorded Scores", '')
                    signature = g.signature
                    g.body = body + '\n\n' + signature
                    print(student.email)
                    print(g.body)
                    g.recipients = [student.email]
                    g.send()
                except:
                    print("failed to send the email.  ", \
                            "Perhaps there is something wrong with the signature file.")
    ui.pause()
Example #3
0
def test_get_inbox_email():
    gm = gmail.Gmail()
    gm.login(email, password)

    inbox = gm.inbox()
    assert inbox is not None

    inbox_email = inbox.mail()
Example #4
0
def reading_mail () :  # this function returns a dictionary with email arguments
	g = gmail.Gmail()
	g.login(credentials['email'], credentials['pass'])  #logging in to gmail server
	unread = g.inbox().mail(unread=True)  #getting all unread mails. It returns all the blank mials
	unread[-1].fetch()   # getting all the mail attributes like body,subject etc
	mail_args = {'subject' : unread[-1].subject , 'msg_body' : unread[-1].body}
	unread[-1].read()  #marking the mail as read
	return mail_args
	g.logout()  #logging out
Example #5
0
def test_that_emails_have_content():
    gm = gmail.Gmail()
    gm.login(email, password)

    emails = gm.inbox().mail()
    assert len(emails) > 0

    first_email = emails[0]
    assert first_email.subject is not None
    assert first_email.body is not None
Example #6
0
def main():
    logger.info('AutoReply script started.')
    logger.info('Reading gmail messages')
    info_form_list = gmail.Gmail().read_messages()
    output_file = open('results.txt', 'w')
    for info_form in info_form_list:
        output_file.write(str(info_form))
        output_file.write('\n<<<-------------->>>\n')
    output_file.close()
    logger.info('Reading Gmail messages completed. Please check results.txt')
Example #7
0
def reading_mail () :  # this function returns a dictionary with email arguments
	g = gmail.Gmail()
	try :
		g.login(os.environ["EMAIL"], os.environ["PASSWORD"])  #logging in to gmail server
	except :
		print ("Unable to authenticate.Got following error :\n{}".format(traceback.format_exc()))
		exit(0)

	unread_mails = g.inbox().mail(unread=True)  #getting all unread mails. It returns all the blank mails
	# total_unread = str(len(unread_mails))
	mail_list = list()
	if len(unread_mails) > 0 :
		for mail in unread_mails :
			mail.fetch()   # getting all the mail attributes like body,subject etc
			# mail_args = {'subject' : mail.subject , 'body' : mail.body , 'sender' : mail.fr}
			msg = "New E-mail !!!\nSender : {}\nSubject : {}".format(mail.fr,mail.subject)
			flag = send_sms(msg)
			if flag :
				mail.read()  #marking the mail as read
		g.logout()  #logging out
Example #8
0
def iterate_gmail():
    conn = gmail.Gmail(EMAIL, PASSWORD)
    msgs = conn.search.unread().all()
    for msg in msgs:
        subject = decode(msg.subject())
        if DEBUG:
            msg.unread()
        date = decode_date(msg.message["Date"])
        body = msg.message.get_payload(decode=True)
        lines = [subject]
        if isinstance(body, list):
            body = body[0].get_payload()
        if body:
            body = body.decode('koi8-r')
            more_lines = body.split('\n')
            lines = lines + more_lines
        new_lines = []
        for line in lines:
            line = line.strip()
            if len(line) > 0:
                new_lines.append(line)
        yield dict(date=date, lines=new_lines)
    conn.logout()
Example #9
0
    sui.initTallyInfo()
    sui.printAccounts()
    f = os.walk(config['detailPath'])
    banks = []
    for path, dirs, files in f:
        for filename in files:
            if filename[:1] == '~':
                continue
            if filename[-4:] != 'xlsx':
                continue
            bankReader = createBankReader(filename, path)
            bankDetail = bankReader.analyseData()
            banks.append(bankDetail)
            # print(bankDetail)
    if config['gmail']:
        g = gmail.Gmail(config)
        messages = g.getTallyMails()
        for message in messages:
            mail = g.getMail(message['id'])
            bankReader = createBankReaderByMail(mail)
            bankDetail = bankReader.analyseData()
            banks.append(bankDetail)

    for bank in banks:
        suiid = bank['suiid']
        suiDetails = sui.accountDetail(suiid, transDate(bank['startDate']),
                                       transDate(bank['endDate']))
        print(suiDetails)
        bankDetails = bank['details']
        # print(bankDetails)
        for bankDetail in bankDetails:
Example #10
0
def test_smtp_login():
    gm = gmail.Gmail()
    gm._connect_smtp()
    gm.smtp.login(email, password)
Example #11
0
def test_smtp_send_text_email():
    gm = gmail.Gmail()

    gm.login(email, password)
    message = gmail.Message.create("Hello", to, text="Hello world")
    gm.send(message)
Example #12
0
import gmail as gm
password = '******'
mailFrom = '*****@*****.**'
message = 'mail cisco meraki'

auth = gm.Gmail(mailFrom, password)
msg = gm.Message(subject, to=mailTo, text=message)
auth.send(msg)
Example #13
0
if __name__ == "__main__":

    now = datetime.datetime.now()
    path = str(now.year) + "_" + str(now.month) + "_" + str(now.day)
    outpath = ".\\" + path + "\\"  # 저장 경로
    if not os.path.isdir(outpath):
        os.makedirs(outpath)
    '''
        다운로드 시간
        Short URL
        Full URL
        파일명
        파일 hash 값
    '''
    gmail = gmail.Gmail(gmail.login_info)
    gmail.read_email_from_gmail()
    '''
        저장된 사진의 GPS 정보
        MD5 / SHA1 해시값
    '''
    gpslist = []
    md5list = []
    sha1list = []
    gParser = gpsParser.GpsParser(gpslist)

    gmail.fileName_list = saveData.search(outpath)
    for file in gmail.file_nameList:
        gps = gParser.getGPS(outpath + file)
        md5_hash = saveData.getHash_MD5(outpath + file)
        sha1_hash = saveData.getHash_SHA1(outpath + file)
Example #14
0
#!/usr/bin/env python

import logging
import os
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import eliza
import gmail
import helpers

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

gmail_sender = gmail.Gmail('*****@*****.**')

updater = Updater(token="430514110:AAG5aF2dSuHJET_dhV77ek-Qv6_wx3_lW2M")
dispatcher = updater.dispatcher


def start(bot, update):
    bot.send_message(chat_id=update.message.chat_id,
                     text="Hello. How are you feeling today?")


def connect(bot, update):
    gmail_sender.send_message('*****@*****.**',
                              'Login to Telegram Home Remote Access',
                              helpers.login_message(helpers.generate_secret()))
    bot.send_message(chat_id=update.message.chat_id, text="Connect")
Example #15
0
#!/usr/bin/python

import time
import gmail

mail = gmail.Gmail("username", "password")

while True:
    count = mail.count()
    print "Rich has " + str(count) + " new emails"

    time.sleep(60)