From a71ee6414a766fd381d0cd3348477e6393c3607a Mon Sep 17 00:00:00 2001 From: Severin Kaderli Date: Tue, 28 May 2019 21:47:40 +0200 Subject: [PATCH] Update count.py Signed-off-by: Severin Kaderli --- system/.config/polybar/scripts/gmail/count.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/system/.config/polybar/scripts/gmail/count.py b/system/.config/polybar/scripts/gmail/count.py index 13d869e..23253a0 100755 --- a/system/.config/polybar/scripts/gmail/count.py +++ b/system/.config/polybar/scripts/gmail/count.py @@ -15,12 +15,11 @@ CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json') if not os.path.isfile(CREDENTIALS_PATH): print(0) - sys.exit() - -try: - gmail = discovery.build( - 'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get()) - labels = gmail.users().labels().get(userId='me', id='INBOX').execute() - print(labels['messagesUnread']) -except Exception as e: - print(0) +else: + try: + gmail = discovery.build( + 'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get()) + labels = gmail.users().labels().get(userId='me', id='INBOX').execute() + print(labels['messagesUnread']) + except Exception as e: + print(0)