Skip to content

Commit

Permalink
Fix uncaught exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tdorssers committed Sep 12, 2021
1 parent 9904869 commit 4681fe8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException
except ImportError:
webdriver = None
try:
Expand Down Expand Up @@ -500,9 +501,9 @@ def show_dialog():

def login(self):
""" Display login dialog and start new thread to get vehicle list """
result = askstring('Login', 'Use browser to login.\nPage Not Found '
'will be shown at success.\n\nEmail:',
initialvalue=self.email)
prompt = 'Email:' if webdriver else 'Use browser to login.\n' \
'Page Not Found will be shown at success.\n\nEmail:'
result = askstring('Login', prompt, initialvalue=self.email)
if result:
self.email = result
self.status.text('Logging in...')
Expand Down Expand Up @@ -976,8 +977,9 @@ def run(self):
try:
self.tesla.fetch_token()
self.vehicles = self.tesla.vehicle_list()
except (teslapy.RequestException, teslapy.OAuth2Error, ValueError) as e:
self.exception = e
except (teslapy.RequestException, teslapy.OAuth2Error,
WebDriverException) as e:
self.exception = str(e).replace('\n', '')

class StatusThread(threading.Thread):
""" Retrieve vehicle status summary """
Expand Down

0 comments on commit 4681fe8

Please sign in to comment.