Beispiel #1
0
def __main__():
    """ Runs all initialization code
	Returns:
		Dictionary: Contains all email information
	"""
    # Gets users total number of messages in all mailboxes
    msgTotal = Gmail.getUserInfo()['messagesTotal']

    start = timer()
    # Get list of `messageTotal` messages
    messages = Gmail.GetMessages().list(msgTotal)
    end = timer()
    print("Time to get ID's from Google:", end - start)

    start = timer()
    # Get list of raw messages
    rawMessage = Gmail.getMessageData(messages, format='raw', log=True)
    end = timer()

    start = timer()
    # Gets message data
    messageData = Gmail.getMessageData(messages, log=True)
    end = timer()
    print("Time to met message data from ID's:", end - start)

    start = timer()
    # Get payload of message data
    payloads = Gmail.getPayload(messageData, log=True)
    end = timer()
    print('Time to get payload from message data:', end - start)

    return payloads
Beispiel #2
0
def testSend():
    """Sends email based of user input"""
    mailData = [
        input('Name: '),
        input('Recipient: '),
        input('Subject: '),
        input('content: ')
    ]

    start = timer()
    Gmail.sendMessage(*mailData)
    end = timer()
    print('Time to send an email:', end - start)
Beispiel #3
0
def addMail():
    unsavedMessages = Gmail.getUserInfo()['messagesTotal'] - messages.count()
    print(unsavedMessages)
    messages_ = Gmail.GetMessages().list(unsavedMessages)
    messageData = Gmail.getMessageData(messages_, log=False)
    payloads = Gmail.getPayload(messageData, log=False)
    parts = Gmail.getEverything(payloads, log=False)
    # parts = json.load(open('bodies.json'))
    # print("Length of parts", len(parts))
    for part in parts:
        message = {}
        for key, value in part.items():
            message[key] = value
        messages.insert_one(message)
    return 'Tested adding python subjects as names for messages'
Beispiel #4
0
def testMockData(payloads):
    """Logs headers and body from payload

	writes data as an object to a json file located in ./logs, also logs
	all html/plain bodies as seperate .txt/.html files within the
	./logs/bodies directory.

	Args:
		payloads (dict): return of getPayload function
	"""
    start = timer()
    messageBodies = Gmail.unpackPayload(payloads, log=True)
    end = timer()
    print('Time to get message bodies:', end - start)
Beispiel #5
0
def debug():
    Gmail.getUserInfo()['messagesTotal']
    return 'Bugs suck!'
Beispiel #6
0
from pymongo import MongoClient
from flask import Flask
from flask_graphql import GraphQLView
from Server.inputs import MessagesInput
from Server.schemas import MessagesSchema
from PyMail import Gmail
import graphene
from flask_cors import CORS
import json
from authentication import auth

Gmail = Gmail()

client = MongoClient(
    'mongodb://*****:*****@ds255332.mlab.com:55332/mailatschool')

app = Flask(__name__)
CORS(app)
db = client.mailatschool

messages = db['messages']


@app.route('/')
def index():
    return "Graph QL"


@app.route('/delete')
def deleteMail():
    messages.drop()