()
| 982 | |
| 983 | |
| 984 | def main(): |
| 985 | command = None |
| 986 | command_args = None |
| 987 | num_args = len(sys.argv) |
| 988 | if num_args == 1: |
| 989 | show_basic_usage() |
| 990 | return |
| 991 | elif num_args == 2: |
| 992 | command = sys.argv[1] |
| 993 | command_args = [] |
| 994 | elif num_args > 2: |
| 995 | command = sys.argv[1] |
| 996 | command_args = sys.argv[2:] |
| 997 | command = command.lower() |
| 998 | |
| 999 | if command == "get" or command == "install": |
| 1000 | if len(command_args) >= 1: |
| 1001 | from seleniumbase.console_scripts import sb_install |
| 1002 | |
| 1003 | need_retry = False |
| 1004 | need_another_retry = False |
| 1005 | retry_msg_1 = "* Unable to download driver! Retrying in 3s..." |
| 1006 | retry_msg_2 = "** Unable to download driver! Retrying in 5s..." |
| 1007 | if " --proxy=" in " ".join(sys.argv): |
| 1008 | from seleniumbase.core import proxy_helper |
| 1009 | for arg in sys.argv: |
| 1010 | if arg.startswith("--proxy="): |
| 1011 | proxy_string = arg.split("--proxy=")[1] |
| 1012 | if "@" in proxy_string: |
| 1013 | proxy_string = proxy_string.split("@")[1] |
| 1014 | proxy_helper.validate_proxy_string(proxy_string) |
| 1015 | break |
| 1016 | try: |
| 1017 | settings.HIDE_DRIVER_DOWNLOADS = False |
| 1018 | sb_install.main() |
| 1019 | except Exception as e: |
| 1020 | invalid_run_cmd = constants.Warnings.INVALID_RUN_COMMAND |
| 1021 | if invalid_run_cmd in str(e): |
| 1022 | raise |
| 1023 | print() |
| 1024 | print(retry_msg_1) |
| 1025 | time.sleep(3) |
| 1026 | print() |
| 1027 | need_retry = True |
| 1028 | if need_retry: |
| 1029 | try: |
| 1030 | sb_install.main() |
| 1031 | except Exception: |
| 1032 | print(retry_msg_2) |
| 1033 | time.sleep(5) |
| 1034 | print() |
| 1035 | need_another_retry = True |
| 1036 | if need_another_retry: |
| 1037 | sb_install.main() |
| 1038 | else: |
| 1039 | show_basic_usage() |
| 1040 | show_install_usage() |
| 1041 | elif command == "commander" or command == "gui": |
no test coverage detected
searching dependent graphs…