Example #1
0
def main():
    MAIL    = 'M'
    NO_MAIL = 'N'
    
    # create Mail object, login get 
    # number of unread emails, then logout
    g = Mail() 
    g.login()
    numUnread = g.getNumUnread()
    g.logout()
    
    # create SConnection object and connect
    # to serial port
    s = SConnection()
    s.connectToSerial('COM3')
    
    # write message to serial depending on if
    # there are unread emails or not
    if numUnread > 0:
        s.writeToSerial(MAIL)
    else:
        s.writeToSerial(NO_MAIL)
    
    # close serial connection
    s.closeSerial() 
Example #2
0
    def notify(self, svn_info, mail_address, cur_revision):
        print "notify revision is " + str(cur_revision)

        mail = Mail(config.email_smtp, "svn monitor", "to " + mail_address, "new revision: " + str(cur_revision), svn_info.path + " updated current revision is: " + str(cur_revision))

        if config.email_use_ssl:
            mail.starttls()

        mail.login(config.email_user, config.email_pwd)
        mail.send(config.email_user, mail_address)

        return
Example #3
0
    def test_send(self):
        try:
            mail = Mail("smtp.qq.com", "test from", "test to", "test subject",
                        "test msg")
            mail.starttls()

            mail.login(config.email_user, config.email_pwd)
            mail.send(config.email_user, "*****@*****.**")
        except Exception as e:
            print e
            exit(0)

        print "send mail complete"
Example #4
0
class Detach:

    MESSAGE_PARTS = '(RFC822.SIZE BODY[HEADER.FIELDS (FROM DATE SUBJECT)] BODY)'    

    def fetch(self, mesg_nums):
        typ, data = self.mail.send_cmd('FETCH', mesg_nums, self.MESSAGE_PARTS)
        result = [ self.parse(data[i:i+2]) for i in range(0, len(data), 2) ]
        self.mail.verbose(pprint.pformat(result))
        return result

    def connect(self, args):
        if not args.host:
            try:
                from imap_config import HOSTNAME
                args.host = HOSTNAME
            except ImportError:
                args.host = None
        self.mail = Mail(args)
    
    def login(self, username):
        password = None
        if not username:         
            try:
                from imap_config import USERNAME, PASSWORD
                username, password = (USERNAME, PASSWORD)
            except ImportError:
                pass
        self.mail.login(username, password)

    def logout(self):
        self.mail.logout()

    def parse(self, data):
        mesg = parse_fetch.parse_fields(data[0][1])
        mesg['num'] = parse_fetch.parse_message_id(data[0][0])
        mesg['size'] = parse_fetch.parse_rfc822_size(data[0][0])
        mesg['num_attachments'] = len(parse_fetch.get_attachment_names(data[1]))
        return mesg

    def search(self, search_criterion):
        typ, data = self.mail.send_cmd('SEARCH', None, search_criterion)
        mesg_nums = data[0].replace(' ', ',')
        mesg = 'SEARCH returned {0} message(s).\n'
        mesg_count = (arg_nums.count(',') + 1) if mesg_nums else 0
        self.mail.verbose(mesg.format(mesg_count))
        return arg.nums

    def select(self, mailbox='INBOX'):
        typ, data = self.mail.send_cmd('SELECT', mailbox)
        mesg = 'Found {0} message(s) in {1!r}.\n'
        self.mail.verbose(mesg.format(data[0], mailbox))
Example #5
0
shutil.rmtree('.\\result\\')
sch()

user = your_pw.user
passwd = your_pw.password
regex = re.compile(
    """(https?:\/\/).?(bitly.kr)\/([a-zA-Z0-9]{4})|(https?:\/\/).?(bit.ly)\/([a-zA-Z0-9]{7})|(https?:\/\/).?(goo.gl)\/([a-zA-Z0-9]{6})|(https?:\/\/).?(me2.do)\/([a-zA-Z0-9]{8})|(https?:\/\/).?(grep.kr)\/([a-zA-Z0-9]{4})|(https?:\/\/).?(hoy.kr)\/([a-zA-Z0-9]{4})"""
)

host = user.split('@')[1].split('.')[0]
#print host

mymail = Mail(host, 'imap')
mymail.connect()
mymail.login(user, passwd)
mymail.inbox()
mails = mymail.search(sender='*****@*****.**')
#mymail.logout()

#print mails
shorturl_list = []
datat = []
data = []

for mm in mails:
    mm.fetch()
    #print mm.body
    #print mm.headers["Date"]
    date = mm.headers["Date"]
    date2 = date.split(' ')
        choice = int(input('Enter your choice: '))

        if choice == 1:
            # Create Dataset
            reply = input(
                'Do you want get emails from your email account? (y/n): '
            )[0].lower()
            if reply == 'n':
                dataset_name = input(
                    'Enter the name of existing dataset folder: ')
                ex.main(dataset_name)
            elif reply == 'y':
                usr = input('Email: ')
                pwd = getpass('Password: '******'Enter a name for your dataset: ')
                    if platform.system() == 'Windows':
                        dataset_path = current_path + dataset_name + "\\"
                    elif platform.system() == 'Linux':
                        dataset_path = current_path + dataset_name + "/"
                    if not os.path.exists(dataset_path):
                        os.mkdir(dataset_path)

                    print('Your Folders:')
                    pprint(e.list())
                    folder_names = []
                    print(
                        'Enter folder names you want in your dataset: (New line when done)'
                    )
Example #7
0
send_by_str = cfg['Spreadsheet']['Send_by_str']
period_before_send = cfg['Main']['Period_before_send'].split(',')
period_before_archive = cfg['Main']['Period_before_arch'].split(',')

# Создаем экземляры классов
temp_logfile = File(Path, path_To_Temperature_Log, logger)
sensor = Sensor(logger, cfg.get('DHT'))
mail = Mail(temp_logfile, logger, cfg.get('email'))
spr_sheet = Spreadsheet(logger, Path, path_To_Temperature_Log,
                        cfg.get('Spreadsheet'))

# Если есть инет, пробуем законнектится
if is_Connected(site_For_Check) == True:
    # Инициализруем почту, если включена отправка почты
    if mail_Status is True:
        mail.login()
        is_Connected_To_Mail = True

    # Инициализруем гугл докс, если они включены в конфиге
    if spreadsheet_Status is True:
        # Логинимся и открываем таблицу
        spr_sheet.login()
        spr_sheet.open()

        # Если нужно, отчищаем гугл таблицу при старте
        if clear_spreadsheet_on_start is True:
            spr_sheet.clear()

            # Создаем описание колонок
            spr_sheet.create_Cols_Description()
	while choice != 5:
		print('\nMenu:')
		print('1 -> Create Dataset.\n2 -> Classify using kNN.\n3 -> Classify using MNB.\n4 -> Exit.')
		choice = int(input('Enter your choice: '))
		
		if choice == 1:
			# Create Dataset
			reply = input('Do you want get emails from your email account? (y/n): ')[0].lower()
			if reply == 'n':
				dataset_name = input('Enter the name of existing dataset folder: ')
				ex.main(dataset_name)
			elif reply == 'y':
				usr = input('Email: ')
				pwd = getpass('Password: '******'Enter a name for your dataset: ')
					if platform.system() == 'Windows':
						dataset_path = current_path + dataset_name + "\\"
					elif platform.system() == 'Linux':
						dataset_path = current_path + dataset_name + "/"
					if not os.path.exists(dataset_path):
						os.mkdir(dataset_path)

					print('Your Folders:')
					pprint(e.list())
					folder_names = []
					print('Enter folder names you want in your dataset: (New line when done)')
					while True:
						name = input()