Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def proccess_bitsc(current,year, month):
- filter_time = False
- dirf = '/home/peter/currens/{}/bin/gps'.format(current)
- year = year
- month = str(month).zfill(2)
- ahora = arrow.get('{}-{}-01'.format(year, month))
- server = 'imap.th31l1_1s10nofthefallen.anywhere'
- user = 'whocares'
- password = 'whocancareless'
- m = imaplib.IMAP4_SSL(server, 993)
- m.login(user, password)
- m.select('inbox')
- imaplib._MAXLINE = 4000000
- ahoraf = ahora.strftime('%d-%b-%Y')
- sv = '(SINCE "{}" Subject "Currency rates")'.format(ahoraf)
- resp, items = m.search(None, sv)
- items = items[0].split()
- for emailid in tqdm(items):
- resp, data = m.fetch(emailid, "(RFC822)")
- email_body = data[0][1]
- mail = email.message_from_string(email_body)
- # if mail.get_content_maintype() != 'multipart': continue
- for part in mail.walk():
- if part.get_filename():
- ffname = dirf + '/' + part.get_filename()
- ffname = re.sub('\r\n', '', ffname).replace(' ', '_')
- open(ffname, 'wb').write(part.get_payload(decode=True))
Advertisement
Add Comment
Please, Sign In to add comment