Skip to content

Commit 18422d3

Browse files
authored
Merge pull request #690 from seleniumbase/colorama-initialization
Make sure to initialize "colorama" before using it
2 parents 808ca14 + b3b0b70 commit 18422d3

File tree

7 files changed

+62
-23
lines changed

7 files changed

+62
-23
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
run: |
3838
sudo apt install google-chrome-stable
3939
sudo apt-get install firefox
40+
- name: Check the console scripts interface
41+
run: |
42+
seleniumbase
43+
sbase
4044
- name: Install chromedriver and geckodriver (Firefox Webdriver)
4145
run: |
4246
seleniumbase install chromedriver

azure-pipelines.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ jobs:
4646
sudo apt-get install firefox
4747
displayName: 'Install Chrome and Firefox'
4848
49+
- script: |
50+
seleniumbase
51+
sbase
52+
displayName: 'Check the console scripts interface'
53+
4954
- script: |
5055
seleniumbase install chromedriver
5156
displayName: 'Install chromedriver'

examples/test_chromedriver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def test_chromedriver_matches_chrome(self):
2323
chromedriver_version = chrome_dict["chromedriverVersion"]
2424
chromedriver_version = chromedriver_version.split(' ')[0]
2525
major_chromedriver_version = chromedriver_version.split('.')[0]
26+
colorama.init(autoreset=True)
2627
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
2728
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
2829
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX

seleniumbase/console_scripts/run.py

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,36 @@
3131
def show_usage():
3232
show_basic_usage()
3333
sc = ("")
34-
sc += ('Type "sbase help [COMMAND]" for specific command info.\n')
35-
sc += ('For info on all commands, type: "seleniumbase --help".\n')
36-
sc += ('* (Use "pytest" for running tests) *\n')
37-
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
38-
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
39-
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
40-
c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
41-
cr = colorama.Style.RESET_ALL
42-
sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr)
43-
sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr)
44-
sc = sc.replace("pytest", c3 + "pytest" + cr)
45-
sc = sc.replace("--help", c4 + "--help" + cr)
46-
sc = sc.replace("help", c4 + "help" + cr)
34+
sc += (' Type "sbase help [COMMAND]" for specific command info.\n')
35+
sc += (' For info on all commands, type: "seleniumbase --help".\n')
36+
sc += (' * (Use "pytest" for running tests) *\n')
37+
if "linux" not in sys.platform:
38+
colorama.init(autoreset=True)
39+
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
40+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
41+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
42+
c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
43+
cr = colorama.Style.RESET_ALL
44+
sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr)
45+
sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr)
46+
sc = sc.replace("pytest", c3 + "pytest" + cr)
47+
sc = sc.replace("--help", c4 + "--help" + cr)
48+
sc = sc.replace("help", c4 + "help" + cr)
4749
print(sc)
4850

4951

5052
def show_basic_usage():
5153
from seleniumbase.console_scripts import logo_helper
5254
seleniumbase_logo = logo_helper.get_seleniumbase_logo()
55+
colorama.init(autoreset=True)
5356
print(seleniumbase_logo)
5457
print("%s" % get_version()[0:1])
5558
print("")
5659
sc = ("")
57-
sc += ('Usage: "seleniumbase [COMMAND] [PARAMETERS]"\n')
58-
sc += ('(simplified): "sbase [COMMAND] [PARAMETERS]"\n')
60+
sc += (' * USAGE: "seleniumbase [COMMAND] [PARAMETERS]"\n')
61+
sc += (' * OR: "sbase [COMMAND] [PARAMETERS]"\n')
5962
sc += ("\n")
60-
sc += ("Commands:\n")
63+
sc += ("COMMANDS:\n")
6164
sc += (" install [DRIVER_NAME] [OPTIONS]\n")
6265
sc += (" mkdir [DIRECTORY_NAME]\n")
6366
sc += (" mkfile [FILE_NAME.py]\n")
@@ -74,17 +77,20 @@ def show_basic_usage():
7477
sc += (" download server (Selenium Server JAR file)\n")
7578
sc += (" grid-hub [start|stop] [OPTIONS]\n")
7679
sc += (" grid-node [start|stop] --hub=[HUB_IP] [OPTIONS]\n")
77-
sc += (' * (EXAMPLE: "sbase install chromedriver latest") *\n')
80+
sc += (' * (EXAMPLE: "sbase install chromedriver latest") *\n')
7881
sc += ("")
79-
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
80-
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
81-
cr = colorama.Style.RESET_ALL
82-
sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr)
83-
sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr)
82+
if "linux" not in sys.platform:
83+
colorama.init(autoreset=True)
84+
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
85+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
86+
cr = colorama.Style.RESET_ALL
87+
sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr)
88+
sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr)
8489
print(sc)
8590

8691

8792
def show_install_usage():
93+
colorama.init(autoreset=True)
8894
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
8995
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
9096
cr = colorama.Style.RESET_ALL
@@ -119,6 +125,7 @@ def show_install_usage():
119125

120126

121127
def show_mkdir_usage():
128+
colorama.init(autoreset=True)
122129
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
123130
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
124131
cr = colorama.Style.RESET_ALL
@@ -140,6 +147,7 @@ def show_mkdir_usage():
140147

141148

142149
def show_mkfile_usage():
150+
colorama.init(autoreset=True)
143151
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
144152
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
145153
cr = colorama.Style.RESET_ALL
@@ -172,6 +180,7 @@ def show_mkfile_usage():
172180

173181

174182
def show_convert_usage():
183+
colorama.init(autoreset=True)
175184
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
176185
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
177186
cr = colorama.Style.RESET_ALL
@@ -191,6 +200,7 @@ def show_convert_usage():
191200

192201

193202
def show_print_usage():
203+
colorama.init(autoreset=True)
194204
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
195205
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
196206
cr = colorama.Style.RESET_ALL
@@ -209,6 +219,7 @@ def show_print_usage():
209219

210220

211221
def show_translate_usage():
222+
colorama.init(autoreset=True)
212223
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
213224
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
214225
cr = colorama.Style.RESET_ALL
@@ -244,6 +255,7 @@ def show_translate_usage():
244255

245256

246257
def show_extract_objects_usage():
258+
colorama.init(autoreset=True)
247259
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
248260
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
249261
cr = colorama.Style.RESET_ALL
@@ -261,6 +273,7 @@ def show_extract_objects_usage():
261273

262274

263275
def show_inject_objects_usage():
276+
colorama.init(autoreset=True)
264277
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
265278
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
266279
cr = colorama.Style.RESET_ALL
@@ -281,6 +294,7 @@ def show_inject_objects_usage():
281294

282295

283296
def show_objectify_usage():
297+
colorama.init(autoreset=True)
284298
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
285299
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
286300
cr = colorama.Style.RESET_ALL
@@ -304,6 +318,7 @@ def show_objectify_usage():
304318

305319

306320
def show_revert_objects_usage():
321+
colorama.init(autoreset=True)
307322
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
308323
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
309324
cr = colorama.Style.RESET_ALL
@@ -325,6 +340,7 @@ def show_revert_objects_usage():
325340

326341

327342
def show_encrypt_usage():
343+
colorama.init(autoreset=True)
328344
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
329345
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
330346
cr = colorama.Style.RESET_ALL
@@ -342,6 +358,7 @@ def show_encrypt_usage():
342358

343359

344360
def show_decrypt_usage():
361+
colorama.init(autoreset=True)
345362
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
346363
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
347364
cr = colorama.Style.RESET_ALL
@@ -359,6 +376,7 @@ def show_decrypt_usage():
359376

360377

361378
def show_download_usage():
379+
colorama.init(autoreset=True)
362380
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
363381
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
364382
cr = colorama.Style.RESET_ALL
@@ -375,6 +393,7 @@ def show_download_usage():
375393

376394

377395
def show_grid_hub_usage():
396+
colorama.init(autoreset=True)
378397
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
379398
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
380399
cr = colorama.Style.RESET_ALL
@@ -402,6 +421,7 @@ def show_grid_hub_usage():
402421

403422

404423
def show_grid_node_usage():
424+
colorama.init(autoreset=True)
405425
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
406426
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
407427
cr = colorama.Style.RESET_ALL
@@ -441,6 +461,7 @@ def show_version_info():
441461

442462

443463
def show_options():
464+
colorama.init(autoreset=True)
444465
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
445466
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
446467
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -497,6 +518,7 @@ def show_options():
497518

498519

499520
def show_detailed_help():
521+
colorama.init(autoreset=True)
500522
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
501523
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
502524
c6 = colorama.Back.CYAN

seleniumbase/console_scripts/sb_install.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,16 @@ def main(override=None):
114114
use_version = ""
115115
new_file = ""
116116
f_name = ""
117+
colorama.init(autoreset=True)
117118
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
118119
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
119120
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
120121
cr = colorama.Style.RESET_ALL
122+
if "linux" in sys_plat:
123+
c1 = ''
124+
c2 = ''
125+
c3 = ''
126+
cr = ''
121127

122128
if name == "chromedriver":
123129
last = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"

seleniumbase/plugins/pytest_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def pytest_addoption(parser):
6262
--visual-baseline (Set the visual baseline for Visual/Layout tests.)
6363
--timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
6464
"""
65+
colorama.init(autoreset=True)
6566
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
6667
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
6768
c3 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
setup(
5656
name='seleniumbase',
57-
version='1.49.8',
57+
version='1.49.9',
5858
description='Web Automation and Test Framework - https://seleniumbase.io',
5959
long_description=long_description,
6060
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)