MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / main

Function main

seleniumbase/utilities/selenium_grid/grid_hub.py:44–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def main():
45 timeout = 230 # The default number of seconds that a test can be idle
46 dir_path = os.path.dirname(os.path.realpath(__file__))
47 num_args = len(sys.argv)
48 if (
49 sys.argv[0].split("/")[-1] == "seleniumbase"
50 or (sys.argv[0].split("\\")[-1] == "seleniumbase")
51 or (sys.argv[0].split("/")[-1] == "sbase")
52 or (sys.argv[0].split("\\")[-1] == "sbase")
53 ):
54 if num_args < 3:
55 invalid_run_command()
56 else:
57 invalid_run_command()
58 grid_hub_command = sys.argv[2]
59 if grid_hub_command not in ["start", "stop", "restart"]:
60 invalid_run_command()
61
62 verbose = "False"
63 if num_args >= 4:
64 options = sys.argv[3:]
65 for option in options:
66 if option == "-v" or option == "--verbose":
67 verbose = "True"
68 elif option.startswith("--timeout=") and len(option) > 10:
69 timeout = option.split("--timeout=")[1]
70 if not timeout.isdigit():
71 msg = '\n"timeout" must be a non-negative integer!\n'
72 print(msg)
73 invalid_run_command(msg)
74 else:
75 invalid_run_command()
76
77 data = []
78 data.append(verbose)
79 file_path = os.path.join(dir_path, "verbose_hub_server.dat")
80 file = open(file_path, mode="w+", encoding="utf-8")
81 file.writelines("\r\n".join(data))
82 file.close()
83
84 from seleniumbase.utilities.selenium_grid import download_selenium_server
85
86 download_selenium_server.main(force_download=False) # Only runs if needed
87
88 if shared_utils.is_linux() or shared_utils.is_mac():
89 if grid_hub_command == "start":
90 subprocess.check_call(
91 dir_path + "/grid-hub start %s" % timeout, shell=True
92 )
93 elif grid_hub_command == "restart":
94 subprocess.check_call(dir_path + "/grid-hub stop .", shell=True)
95 subprocess.check_call(
96 dir_path + "/grid-hub start %s" % timeout, shell=True
97 )
98 elif grid_hub_command == "stop":
99 subprocess.check_call(dir_path + "/grid-hub stop .", shell=True)
100 else:
101 invalid_run_command()

Callers 1

grid_hub.pyFile · 0.70

Calls 3

closeMethod · 0.80
mainMethod · 0.80
invalid_run_commandFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…