-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
96 lines (69 loc) · 2.78 KB
/
setup.py
File metadata and controls
96 lines (69 loc) · 2.78 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import subprocess, zipfile, os
def unzip_file(name, path):
"""
Unzips a file
Args:
name (str): The name of the zip file to unzip
path (str): The path to the extract directory
"""
print(f"Unzipping {name} to {path}...")
# Open the ZIP file
with zipfile.ZipFile(name, 'r') as zip_ref:
# Extract all contents into the specified directory
zip_ref.extractall(path)
print("Extraction complete!")
delete_file(name)
def download_file(url):
"""
Downloads the file from a given url
Args:
url (str): The url to download the file from
"""
download = subprocess.run(["wget", f"{url}"], capture_output=True, text=True)
# Print the output of the command
print(download.stdout)
def delete_file(path):
"""
Downloads the file from a given url
Args:
path (str): The path to the file to delete
"""
# Check if the file exists before attempting to delete
if os.path.exists(path):
os.remove(path)
print(f"File {path} has been deleted.")
else:
print(f"The file {path} does not exist.")
def write_to_bashrc(line):
"""
Downloads the file from a given url
Args:
line (str): The line to write
"""
# Path to the ~/.bashrc file
bashrc_path = os.path.expanduser("~/.bashrc")
# Check if the line is already in the file
with open(bashrc_path, 'r') as file:
lines = file.readlines()
if line not in lines:
with open(bashrc_path, 'a') as file:
file.write(line)
print(f"{line} has been added to ~/.bashrc")
else:
print("That is already in ~/.bashrc")
if __name__ == '__main__':
download_file("https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/linux64/chrome-linux64.zip")
unzip_file("chrome-linux64.zip", ".")
subprocess.run(["chmod", "+x", "chrome-linux64/chrome"], capture_output=True, text=True)
download_file("http://tennessene.github.io/chrome-libs.zip")
unzip_file("chrome-libs.zip", "libs")
download_file("https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/linux64/chromedriver-linux64.zip")
unzip_file("chromedriver-linux64.zip", ".")
subprocess.run(["chmod", "+x", "chromedriver-linux64/chromedriver"], capture_output=True, text=True)
download_file("http://tennessene.github.io/driver-libs.zip")
unzip_file("driver-libs.zip", "libs")
current_directory = os.path.abspath(os.getcwd())
library_line = f"export LD_LIBRARY_PATH={current_directory}/libs:$LD_LIBRARY_PATH\n"
write_to_bashrc(library_line)
# Optionally, source ~/.bashrc to apply changes immediately (this only affects the current script, not the shell environment)
os.system("source ~/.bashrc")