Skip to content

Commit bcb5b93

Browse files
committed
Optimize "colorama" / speed up console scripts output
1 parent 5ccb413 commit bcb5b93

File tree

1 file changed

+1
-22
lines changed
  • seleniumbase/console_scripts

1 file changed

+1
-22
lines changed

seleniumbase/console_scripts/run.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import colorama
2828
import sys
29+
colorama.init(autoreset=True)
2930

3031

3132
def show_usage():
@@ -35,7 +36,6 @@ def show_usage():
3536
sc += (' For info on all commands, type: "seleniumbase --help".\n')
3637
sc += (' * (Use "pytest" for running tests) *\n')
3738
if "linux" not in sys.platform:
38-
colorama.init(autoreset=True)
3939
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
4040
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
4141
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -52,7 +52,6 @@ def show_usage():
5252
def show_basic_usage():
5353
from seleniumbase.console_scripts import logo_helper
5454
seleniumbase_logo = logo_helper.get_seleniumbase_logo()
55-
colorama.init(autoreset=True)
5655
print(seleniumbase_logo)
5756
print("%s" % get_version()[0:1])
5857
print("")
@@ -80,7 +79,6 @@ def show_basic_usage():
8079
sc += (' * (EXAMPLE: "sbase install chromedriver latest") *\n')
8180
sc += ("")
8281
if "linux" not in sys.platform:
83-
colorama.init(autoreset=True)
8482
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
8583
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
8684
cr = colorama.Style.RESET_ALL
@@ -90,7 +88,6 @@ def show_basic_usage():
9088

9189

9290
def show_install_usage():
93-
colorama.init(autoreset=True)
9491
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
9592
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
9693
cr = colorama.Style.RESET_ALL
@@ -125,7 +122,6 @@ def show_install_usage():
125122

126123

127124
def show_mkdir_usage():
128-
colorama.init(autoreset=True)
129125
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
130126
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
131127
cr = colorama.Style.RESET_ALL
@@ -147,7 +143,6 @@ def show_mkdir_usage():
147143

148144

149145
def show_mkfile_usage():
150-
colorama.init(autoreset=True)
151146
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
152147
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
153148
cr = colorama.Style.RESET_ALL
@@ -180,7 +175,6 @@ def show_mkfile_usage():
180175

181176

182177
def show_convert_usage():
183-
colorama.init(autoreset=True)
184178
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
185179
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
186180
cr = colorama.Style.RESET_ALL
@@ -200,7 +194,6 @@ def show_convert_usage():
200194

201195

202196
def show_print_usage():
203-
colorama.init(autoreset=True)
204197
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
205198
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
206199
cr = colorama.Style.RESET_ALL
@@ -219,7 +212,6 @@ def show_print_usage():
219212

220213

221214
def show_translate_usage():
222-
colorama.init(autoreset=True)
223215
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
224216
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
225217
cr = colorama.Style.RESET_ALL
@@ -255,7 +247,6 @@ def show_translate_usage():
255247

256248

257249
def show_extract_objects_usage():
258-
colorama.init(autoreset=True)
259250
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
260251
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
261252
cr = colorama.Style.RESET_ALL
@@ -273,7 +264,6 @@ def show_extract_objects_usage():
273264

274265

275266
def show_inject_objects_usage():
276-
colorama.init(autoreset=True)
277267
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
278268
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
279269
cr = colorama.Style.RESET_ALL
@@ -294,7 +284,6 @@ def show_inject_objects_usage():
294284

295285

296286
def show_objectify_usage():
297-
colorama.init(autoreset=True)
298287
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
299288
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
300289
cr = colorama.Style.RESET_ALL
@@ -318,7 +307,6 @@ def show_objectify_usage():
318307

319308

320309
def show_revert_objects_usage():
321-
colorama.init(autoreset=True)
322310
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
323311
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
324312
cr = colorama.Style.RESET_ALL
@@ -340,7 +328,6 @@ def show_revert_objects_usage():
340328

341329

342330
def show_encrypt_usage():
343-
colorama.init(autoreset=True)
344331
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
345332
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
346333
cr = colorama.Style.RESET_ALL
@@ -358,7 +345,6 @@ def show_encrypt_usage():
358345

359346

360347
def show_decrypt_usage():
361-
colorama.init(autoreset=True)
362348
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
363349
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
364350
cr = colorama.Style.RESET_ALL
@@ -376,7 +362,6 @@ def show_decrypt_usage():
376362

377363

378364
def show_download_usage():
379-
colorama.init(autoreset=True)
380365
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
381366
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
382367
cr = colorama.Style.RESET_ALL
@@ -393,7 +378,6 @@ def show_download_usage():
393378

394379

395380
def show_grid_hub_usage():
396-
colorama.init(autoreset=True)
397381
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
398382
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
399383
cr = colorama.Style.RESET_ALL
@@ -421,7 +405,6 @@ def show_grid_hub_usage():
421405

422406

423407
def show_grid_node_usage():
424-
colorama.init(autoreset=True)
425408
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
426409
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
427410
cr = colorama.Style.RESET_ALL
@@ -461,7 +444,6 @@ def show_version_info():
461444

462445

463446
def show_options():
464-
colorama.init(autoreset=True)
465447
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
466448
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
467449
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -518,7 +500,6 @@ def show_options():
518500

519501

520502
def show_detailed_help():
521-
colorama.init(autoreset=True)
522503
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
523504
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
524505
c6 = colorama.Back.CYAN
@@ -590,7 +571,6 @@ def main():
590571
elif command == "print":
591572
if len(command_args) >= 1:
592573
if sys.version_info[0] == 2:
593-
colorama.init(autoreset=True)
594574
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
595575
cr = colorama.Style.RESET_ALL
596576
msg = '"sbase print" does NOT support Python 2! '
@@ -606,7 +586,6 @@ def main():
606586
elif command == "translate":
607587
if len(command_args) >= 1:
608588
if sys.version_info[0] == 2:
609-
colorama.init(autoreset=True)
610589
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
611590
cr = colorama.Style.RESET_ALL
612591
msg = "The SeleniumBase Translator does NOT support Python 2!"

0 commit comments

Comments
 (0)