Update count.py

Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
Severin Kaderli 2019-05-28 21:47:40 +02:00
parent 56626047c5
commit a71ee6414a
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4

View file

@ -15,12 +15,11 @@ CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json')
if not os.path.isfile(CREDENTIALS_PATH): if not os.path.isfile(CREDENTIALS_PATH):
print(0) print(0)
sys.exit() else:
try:
try: gmail = discovery.build(
gmail = discovery.build( 'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get())
'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get()) labels = gmail.users().labels().get(userId='me', id='INBOX').execute()
labels = gmail.users().labels().get(userId='me', id='INBOX').execute() print(labels['messagesUnread'])
print(labels['messagesUnread']) except Exception as e:
except Exception as e: print(0)
print(0)