@@ -737,11 +737,13 @@ def show_instructions(self, info: VerificationInfo) -> None:
737737 def set_status (self , status : str ):
738738 self ._status = status
739739
740- def show_progress (self , status : Optional [str ] = None ):
740+ def show_progress (self , status : Optional [str ] = None , include_bar : bool = True ):
741741 if status :
742742 self .set_status (status )
743- progress_bar = self ._progress_bar .get (fraction = 1.0 - self .elapsed () / self .timeout )
744- text = f"{ progress_bar } { self ._status } "
743+ text = self ._status
744+ if include_bar :
745+ progress_bar = self ._progress_bar .get (fraction = 1.0 - self .elapsed () / self .timeout )
746+ text = f"{ progress_bar } { text } "
745747 self ._display (f"{ text [:self ._max_width ]: <{self ._max_width }s} " , end = "\r " )
746748
747749 def close (self ):
@@ -775,13 +777,15 @@ def _instructions(self, info: VerificationInfo) -> str:
775777 def show_instructions (self , info : VerificationInfo ) -> None :
776778 self ._instructions_display .update ({"text/html" : self ._instructions (info = info )}, raw = True )
777779
778- def show_progress (self , status : Optional [str ] = None ):
779- # TODO Add emoticons to status?
780+ def show_progress (self , status : Optional [str ] = None , include_bar : bool = True ):
780781 if status :
781782 self .set_status (status )
782- progress_bar = self ._progress_bar .get (fraction = 1.0 - self .elapsed () / self .timeout )
783783 icon = self ._status_icon (self ._status )
784- self ._progress_display .update ({"text/html" : f"<code>{ progress_bar } </code> { icon } { self ._status } " }, raw = True )
784+ text = f"{ icon } { self ._status } "
785+ if include_bar :
786+ progress_bar = self ._progress_bar .get (fraction = 1.0 - self .elapsed () / self .timeout )
787+ text = f"<code>{ progress_bar } </code> { text } "
788+ self ._progress_display .update ({"text/html" : text }, raw = True )
785789
786790 def _status_icon (self , status : str ) -> str :
787791 status = status .lower ()
@@ -790,7 +794,7 @@ def _status_icon(self, status: str) -> str:
790794 elif "success" in status :
791795 return "\u2705 " # Green check mark
792796 elif "timed out" in status :
793- return "\u274C " # Red cross mark
797+ return "\u274C " # Red cross mark
794798 else :
795799 return ""
796800
@@ -906,8 +910,7 @@ def get_tokens(self, request_refresh_token: bool = False) -> AccessTokenResult:
906910 resp = self ._requests .post (url = token_endpoint , data = post_data , timeout = 5 )
907911 if resp .status_code == 200 :
908912 log .info (f"[{ elapsed ():5.1f} s] Authorized successfully." )
909- poll_ui .show_progress (status = "Authorized successfully" )
910- # TODO remove progress bar when authorized succesfully?
913+ poll_ui .show_progress (status = "Authorized successfully" , include_bar = False )
911914 return self ._get_access_token_result (data = resp .json ())
912915 else :
913916 try :
@@ -927,5 +930,5 @@ def get_tokens(self, request_refresh_token: bool = False) -> AccessTokenResult:
927930 )
928931 next_poll = elapsed () + poll_interval
929932
930- poll_ui .show_progress (status = "Timed out" )
933+ poll_ui .show_progress (status = "Timed out" , include_bar = False )
931934 raise OidcDeviceCodePollTimeout (f"Timeout ({ self ._max_poll_time :.1f} s) while polling for access token." )
0 commit comments