-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathset_geckodriver_path.py
More file actions
49 lines (29 loc) · 1.09 KB
/
set_geckodriver_path.py
File metadata and controls
49 lines (29 loc) · 1.09 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
import os
import sys
import platform
def get_os_version():
return platform.system()
def add_geckodriver_to_PATH():
current_path = os.getcwd()
#print("PATH before:")
#print(os.environ["PATH"])
if get_os_version() == "Linux":
print("Linux detected platform.")
geckodriver_path = os.path.join(current_path, "geckodriver-v0.28.0-linux64")
if geckodriver_path in os.environ["PATH"]:
print("Geckodriver already in PATH.")
else:
os.environ["PATH"] += os.pathsep + geckodriver_path
print("Geckodriver added in PATH.")
elif get_os_version() == "Windows":
print("Windows detected platform.")
geckodriver_path = os.path.join(current_path, "geckodriver.exe")
if geckodriver_path in os.environ["PATH"]:
print("Geckodriver already in PATH.")
else:
os.environ["PATH"] += os.pathsep + geckodriver_path
print("Geckodriver added in PATH.")
else:
print("OS not yet available.")
#print("PATH after:")
#print(os.environ["PATH"])