This repository was archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
executable file
·52 lines (42 loc) · 1.66 KB
/
Copy pathchecker.py
File metadata and controls
executable file
·52 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from sys import exit, platform
from socket import create_connection
from socket import error as socket_exceptions
from requests import get
from requests import ConnectionError as requests_exceptions
from selenium import webdriver
from selenium.common.exceptions import WebDriverException as selenium_exceptions
from argument import args
from environment import \
current_path, set_user_file, del_user_file, \
download_chrome_driver, del_chrome_driver
def check():
print("Check the current environment...", flush=True)
if not platform.startswith("linux"):
exit('This platform is not supported.')
try:
create_connection(("1.1.1.1", 80), timeout=3).close()
except socket_exceptions:
exit("Please check your internet connection.")
except Exception as error:
exit(error)
for _ in range(2):
try:
download_chrome_driver(overwrite=False)
opts = webdriver.ChromeOptions()
opts.headless = True
webdriver.Chrome(executable_path=f"{current_path}/chromedriver", options=opts).close()
break
except selenium_exceptions as error:
del_chrome_driver()
continue
except Exception as error:
exit(error)
else:
exit("Download ChromeDriver failed. \nPlease re-download the driver via https://sites.google.com/a/chromium.org/chromedriver.")
try:
get("https://cdx.nchc.org.tw", timeout=3).close()
except requests_exceptions:
exit("CDX cannot be reached. Please try again later.")
except Exception as error:
exit(error)
print("Now, it's ready to go.", flush=True)