|
14 | 14 | from selenium import webdriver |
15 | 15 | from selenium.webdriver.support import expected_conditions as EC |
16 | 16 | from selenium.webdriver.support.ui import WebDriverWait |
| 17 | + from selenium.common.exceptions import WebDriverException |
17 | 18 | except ImportError: |
18 | 19 | webdriver = None |
19 | 20 | try: |
@@ -500,9 +501,9 @@ def show_dialog(): |
500 | 501 |
|
501 | 502 | def login(self): |
502 | 503 | """ 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) |
506 | 507 | if result: |
507 | 508 | self.email = result |
508 | 509 | self.status.text('Logging in...') |
@@ -976,8 +977,9 @@ def run(self): |
976 | 977 | try: |
977 | 978 | self.tesla.fetch_token() |
978 | 979 | 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', '') |
981 | 983 |
|
982 | 984 | class StatusThread(threading.Thread): |
983 | 985 | """ Retrieve vehicle status summary """ |
|
0 commit comments