File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,18 @@ def evoke_search_error(self, error_statement):
1818 ]
1919 for text_to_print in print_text :
2020 print (text_to_print )
21+
22+ class LoginError ():
23+ def __init__ (self , error_statement , success = False ):
24+ # the error statement
25+ self .error_statement = error_statement
26+
27+ # success determines the color of message
28+ self .success = success
29+
30+ self .evoke_search_error ()
31+
32+ def evoke_search_error (self ):
33+ color = "green" if self .success else "red"
34+ print_text = colored (self .error_statement , color )
35+ print (print_text )
Original file line number Diff line number Diff line change 11import os
22
33from .utility import get_browser_driver
4+ from .error import LoginError
45from .settings import LOGIN_PATH
56from .settings import TOKEN_FILE_PATH
67
78from selenium .webdriver .common .by import By
89from selenium .webdriver .support .ui import WebDriverWait
910from selenium .webdriver .support import expected_conditions as EC
1011
12+ from rich import console
13+
1114def get_token_from_cookie (cookie , token ):
1215 for el in cookie :
1316 if el ['name' ] == token :
@@ -72,17 +75,18 @@ def get_tokenv2_cookie(self):
7275 if not self .tokenv2_cookie :
7376 try :
7477 self .tokenv2_cookie = get_token_from_file ()
78+ LoginError ("Login Successful" , success = True )
7579 except Exception :
7680 try :
7781 cookies = get_cookies_from_login ()
7882 self .tokenv2_cookie = get_token_from_cookie (cookies , 'token_v2' )
7983 except Exception as e :
80- print (e )
8184 self .tokenv2_cookie = None
8285 finally :
8386 if self .tokenv2_cookie :
8487 os .environ [self .tokenv2_key ] = str (self .tokenv2_cookie )
88+ LoginError ("Login Successful" , success = True )
8589 self .save_token_file ()
8690 else :
87- raise RuntimeError ( "Cookie unreachable" )
91+ LoginError ( "Login Failed" , success = False )
8892 return self .get_tokenv2_cookie
You can’t perform that action at this time.
0 commit comments