aboutsummaryrefslogtreecommitdiffstats
path: root/python/download_emails.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/download_emails.py')
-rw-r--r--python/download_emails.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/python/download_emails.py b/python/download_emails.py
index 8c2e980e..6127e38c 100644
--- a/python/download_emails.py
+++ b/python/download_emails.py
@@ -46,18 +46,17 @@ def ListMessagesWithLabels(service, user_id, label_ids=[]):
def ListHistory(service, user_id, label_id=None, start_history_id=10000):
- """List History of all changes to the user's mailbox.
+ """List History of all changes to the user's mailbox.
- Args:
+ Args:
service: Authorized Gmail API service instance.
user_id: User's email address. The special value "me"
can be used to indicate the authenticated user.
start_history_id: Only return Histories at or after start_history_id.
- Returns:
+ Returns:
A list of mailbox changes that occurred after the start_history_id.
- """
- try:
+ """
history = (service.users().history().list(userId=user_id,
startHistoryId=start_history_id,
historyTypes="messageAdded",
@@ -79,9 +78,6 @@ def ListHistory(service, user_id, label_id=None, start_history_id=10000):
for c in change['messagesAdded']:
yield c['message']
- except errors.HttpError as error:
- print('An error occurred:', error)
-
def labels_dict(service, user_id):
"""Returns a dictionary mapping labels to labelids.
@@ -185,4 +181,8 @@ def save_emails(update=True):
if __name__ == '__main__':
- save_emails()
+ try:
+ save_emails()
+ except errors.HttpError as e:
+ print(e)
+ save_emails(update=False)