mirror of
https://github.com/streetturtle/awesome-wm-widgets.git
synced 2024-11-17 07:49:09 +01:00
fix for python 3
May be it will be useful for someone
This commit is contained in:
parent
257dff3b6c
commit
69825ad238
1 changed files with 18 additions and 16 deletions
|
@ -15,14 +15,16 @@ def process_mailbox(M):
|
|||
if rv != 'OK':
|
||||
print "ERROR getting message", num
|
||||
return
|
||||
|
||||
msg = email.message_from_string(data[0][1])
|
||||
print 'From:', msg['From']
|
||||
print 'Subject: %s' % (msg['Subject'])
|
||||
date_tuple = email.utils.parsedate_tz(msg['Date'])
|
||||
msg = email.message_from_bytes(data[0][1])
|
||||
for header in [ 'From', 'Subject', 'Date' ]:
|
||||
hdr = email.header.make_header(email.header.decode_header(msg[header]))
|
||||
if header == 'Date':
|
||||
date_tuple = email.utils.parsedate_tz(str(hdr))
|
||||
if date_tuple:
|
||||
local_date = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
|
||||
print "Local Date:", local_date.strftime("%a, %d %b %Y %H:%M:%S")
|
||||
print("{}: {}".format(header, local_date.strftime("%a, %d %b %Y %H:%M:%S")))
|
||||
else:
|
||||
print('{}: {}'.format(header, hdr)
|
||||
# with code below you can process text of email
|
||||
# if msg.is_multipart():
|
||||
# for payload in msg.get_payload():
|
||||
|
|
Loading…
Reference in a new issue