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

Function main

seleniumbase/utilities/selenium_grid/grid_node.py:47–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46
47def main():
48 # Install chromedriver if not installed
49 if not is_chromedriver_on_path():
50 from seleniumbase.console_scripts import sb_install
51
52 sys_args = sys.argv # Save a copy of current sys args
53 print("\nWarning: chromedriver not found. Installing now:")
54 sb_install.main(override="chromedriver")
55 sys.argv = sys_args # Put back the original sys args
56
57 dir_path = os.path.dirname(os.path.realpath(__file__))
58 num_args = len(sys.argv)
59 if (
60 sys.argv[0].split("/")[-1] == "seleniumbase"
61 or (sys.argv[0].split("\\")[-1] == "seleniumbase")
62 or (sys.argv[0].split("/")[-1] == "sbase")
63 or (sys.argv[0].split("\\")[-1] == "sbase")
64 ):
65 if num_args < 3:
66 invalid_run_command()
67 else:
68 invalid_run_command()
69 grid_hub_command = sys.argv[2]
70 if grid_hub_command not in ["start", "stop", "restart"]:
71 invalid_run_command()
72
73 server_ip = "127.0.0.1"
74 verbose = "False"
75 if num_args >= 4:
76 options = sys.argv[3:]
77 for option in options:
78 if option.startswith("--hub=") and (
79 len(option.split("--hub=")[1]) > 0
80 ):
81 server_ip = option.split("--hub=")[1]
82 elif option == "-v" or option == "--verbose":
83 verbose = "True"
84 else:
85 invalid_run_command()
86
87 data = []
88 data.append(server_ip)
89 file_path = os.path.join(dir_path, "ip_of_grid_hub.dat")
90 file = open(file_path, mode="w+", encoding="utf-8")
91 file.writelines("\r\n".join(data))
92 file.close()
93
94 data = []
95 data.append(verbose)
96 file_path = os.path.join(dir_path, "verbose_node_server.dat")
97 file = open(file_path, mode="w+", encoding="utf-8")
98 file.writelines("\r\n".join(data))
99 file.close()
100
101 from seleniumbase.utilities.selenium_grid import download_selenium_server
102
103 download_selenium_server.main(force_download=False) # Only runs if needed
104

Callers 1

grid_node.pyFile · 0.70

Calls 4

is_chromedriver_on_pathFunction · 0.85
mainMethod · 0.80
closeMethod · 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…