imap module: handle OAuth TransportError
@@ -182,6 +182,7 @@ class Py3status:
def _get_creds(self):
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
+ from google.auth.exceptions import TransportError
import pickle
self.creds = None
@@ -192,6 +193,7 @@ class Py3status:
self.creds = pickle.load(token)
if not self.creds or not self.creds.valid:
+ try:
if self.creds and self.creds.expired and self.creds.refresh_token:
# Credentials expired but contain refresh token
self.creds.refresh(Request())
@@ -204,6 +206,9 @@ class Py3status:
# Save the credentials for the next run
with open(self.auth_token, "wb") as token:
pickle.dump(self.creds, token)
+ except TransportError as e:
+ # Treat the same as a socket_error
+ raise socket_error(e)
def _connection_ssl(self):
if self.client_secret:
