This repository was archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver_updater.py
More file actions
60 lines (51 loc) · 2.21 KB
/
driver_updater.py
File metadata and controls
60 lines (51 loc) · 2.21 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
53
54
55
56
57
58
59
60
# Author: Mohammed Sazid Al Rashid
import os
import sys
from pathlib import Path
try:
import webdrivermanager
except:
print("Could not find module webdrivermanager. Install by running command:")
print("> pip install webdrivermanager")
print("Press any key or [ENTER] to exit.")
input()
def update(pathname):
driver_download_path = Path(pathname) / Path("webdrivers")
drivers = webdrivermanager.AVAILABLE_DRIVERS
for name in drivers:
try:
print("\n%s Driver..." % name.upper())
driver = drivers[name](
download_root=driver_download_path, link_path=pathname
)
if __name__ == "__main__":
print("Specify the version number of %s driver and press [Enter].\n" % name +
"Press [Enter] for the latest version of %s driver \n" % name +
"Press [Space] + [Enter] to skip the downloading of %s driver " % name
)
version = input()
if len(version) == 0:
print("Downloading the latest version of %s driver. Please wait a bit..." % name)
driver.download_and_install()
elif version == " ":
print("Skipping download of %s" % name)
continue
else:
print("Downloading the %s version of %s driver. Please wait a bit..." % (version, name))
driver.download_and_install(version)
else:
print("Downloading the latest version of %s driver. Please wait a bit..." % name)
driver.download_and_install()
except RuntimeError:
print("Skipping download of %s" % name)
def main():
# Scripts folder is usually placed in the PATH. So we'll download the drivers there
PYTHON_DIR = os.path.dirname(sys.executable)
PYTHON_SCRIPTS_DIR = os.path.join(PYTHON_DIR, "Scripts")
print("Starting update. Drivers will be placed in the following directory:")
print("> %s" % PYTHON_SCRIPTS_DIR)
update(pathname=PYTHON_SCRIPTS_DIR)
if __name__ == "__main__":
main()
print("\nUpdate complete. Press any key or [ENTER] to exit.")
input()