1616from time import sleep
1717from openad .helpers .general import is_notebook_mode
1818from openad .helpers .output import output_text
19+ from openad .app .global_var_lib import GLOBAL_SETTINGS
1920
2021
2122if is_notebook_mode ():
2526
2627
2728class Spinner (Halo ):
28- verbose = True
2929
30- def __init__ (self , verbose = True ):
31- self .verbose = verbose
30+ def __init__ (self ):
3231
3332 # Fancy spinner, but requires more CPU, blocking the main thread
34- # To do: see is separating thread for spinner resolves this
33+ # To do: see if separating thread for spinner resolves this
3534 wave_spinner = {
3635 "interval" : 700 ,
3736 "frames" : [
@@ -47,7 +46,7 @@ def __init__(self, verbose=True):
4746 ],
4847 }
4948
50- if self . verbose is True :
49+ if GLOBAL_SETTINGS [ "display" ] != "api" :
5150 super ().__init__ (spinner = "triangle" , color = "white" , interval = 700 )
5251
5352 # Fancy spinner
@@ -57,7 +56,7 @@ def __init__(self, verbose=True):
5756 # https://github.com/sindresorhus/cli-spinners/blob/dac4fc6571059bb9e9bc204711e9dfe8f72e5c6f/spinners.json
5857
5958 def start (self , text = None , no_format = False ):
60- if self . verbose is True :
59+ if GLOBAL_SETTINGS [ "display" ] != "api" :
6160 if no_format :
6261 text = output_text (text , return_val = True , jup_return_format = "plain" ) if text else None
6362 else :
@@ -67,24 +66,24 @@ def start(self, text=None, no_format=False):
6766 super ().start (text )
6867
6968 def succeed (self , * args , ** kwargs ):
70- if self . verbose is True :
69+ if GLOBAL_SETTINGS [ "display" ] != "api" :
7170 return super ().succeed (* args , ** kwargs )
7271
7372 def info (self , * args , ** kwargs ):
74- if self . verbose is True :
73+ if GLOBAL_SETTINGS [ "display" ] != "api" :
7574 super ().info (* args , ** kwargs )
7675 return super ().start (* args , ** kwargs )
7776
7877 def warn (self , * args , ** kwargs ):
79- if self . verbose is True :
78+ if GLOBAL_SETTINGS [ "display" ] != "api" :
8079 return super ().warn (* args , ** kwargs )
8180
8281 def fail (self , * args , ** kwargs ):
83- if self . verbose is True :
82+ if GLOBAL_SETTINGS [ "display" ] != "api" :
8483 return super ().fail (* args , ** kwargs )
8584
8685 def stop (self ):
87- if self . verbose is True :
86+ if GLOBAL_SETTINGS [ "display" ] != "api" :
8887 return super ().stop ()
8988
9089 def countdown (
@@ -108,15 +107,15 @@ def countdown(
108107 """
109108
110109 msg = msg or "Waiting {sec} seconds before retrying"
111- spinner .start (msg .format (sec = seconds ))
110+ self .start (msg .format (sec = seconds ))
112111 sleep (1 )
113112 if seconds > 1 :
114113 self .countdown (seconds - 1 , msg , stop_msg )
115114 else :
116115 if stop_msg :
117- spinner .start (stop_msg )
116+ self .start (stop_msg )
118117 else :
119- spinner .stop ()
118+ self .stop ()
120119 return True
121120
122121
0 commit comments