aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/download_emails.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/python/download_emails.py b/python/download_emails.py
index b9ff318b..ae386751 100644
--- a/python/download_emails.py
+++ b/python/download_emails.py
@@ -10,6 +10,7 @@ from oauth2client import client
from oauth2client import tools
import json
import base64
+import binascii
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
@@ -108,11 +109,16 @@ def main():
current_msgs = set([f.name for f in p.iterdir() if f.is_file()])
for msg in ListMessagesWithLabels(service, 'me', labelsdict['swaptions']):
if msg['id'] not in current_msgs:
- subject, content = msg_content(get_msg(service, 'me', msg['id']))
- email = Path("quotes/{0}".format(msg['id']))
- with email.open("w") as fh:
- fh.write(subject + "\r\n")
- fh.write(content)
+ try:
+ subject, content = msg_content(get_msg(service, 'me', msg['id']))
+ except binascii.Error:
+ print("error decoding {0}".format(msg['id']))
+ continue
+ else:
+ email = Path("quotes/{0}".format(msg['id']))
+ with email.open("w") as fh:
+ fh.write(subject + "\r\n")
+ fh.write(content)
if __name__ == '__main__':
main()