Skip to content

Commit 4681fe8

Browse files
committed
Fix uncaught exception
1 parent 9904869 commit 4681fe8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gui.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from selenium import webdriver
1515
from selenium.webdriver.support import expected_conditions as EC
1616
from selenium.webdriver.support.ui import WebDriverWait
17+
from selenium.common.exceptions import WebDriverException
1718
except ImportError:
1819
webdriver = None
1920
try:
@@ -500,9 +501,9 @@ def show_dialog():
500501

501502
def login(self):
502503
""" Display login dialog and start new thread to get vehicle list """
503-
result = askstring('Login', 'Use browser to login.\nPage Not Found '
504-
'will be shown at success.\n\nEmail:',
505-
initialvalue=self.email)
504+
prompt = 'Email:' if webdriver else 'Use browser to login.\n' \
505+
'Page Not Found will be shown at success.\n\nEmail:'
506+
result = askstring('Login', prompt, initialvalue=self.email)
506507
if result:
507508
self.email = result
508509
self.status.text('Logging in...')
@@ -976,8 +977,9 @@ def run(self):
976977
try:
977978
self.tesla.fetch_token()
978979
self.vehicles = self.tesla.vehicle_list()
979-
except (teslapy.RequestException, teslapy.OAuth2Error, ValueError) as e:
980-
self.exception = e
980+
except (teslapy.RequestException, teslapy.OAuth2Error,
981+
WebDriverException) as e:
982+
self.exception = str(e).replace('\n', '')
981983

982984
class StatusThread(threading.Thread):
983985
""" Retrieve vehicle status summary """

0 commit comments

Comments
 (0)