-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvent.py
More file actions
62 lines (50 loc) · 2.23 KB
/
vent.py
File metadata and controls
62 lines (50 loc) · 2.23 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
import os
import sys
import wget
import csv
file_dir = os.path.dirname(os.path.abspath(__file__))
def install_package(package_name):
print(f"Installing package: {package_name}...")
# Define where to store installed packages (same directory as this script/executable)
base_dir = os.path.dirname(os.path.abspath(__file__))
packages_dir = os.path.join(base_dir, "packages")
# Create the directory if it doesn't exist
os.makedirs(packages_dir, exist_ok=True)
# Temporary directory to download the CSV
os.makedirs(os.path.join(file_dir, "tmp"), exist_ok=True)
# Download the packages CSV file
csv_url = "https://sussyos.github.io/api/susScript/vent/packages.csv"
file = wget.download(csv_url, out=os.path.join(file_dir, "tmp", "packages.csv"))
# Read the CSV to get package information
packages = {}
with open(os.path.join(file_dir, "tmp", "packages.csv"), "r") as f:
reader = csv.DictReader(f)
for row in reader:
packages[row['name']] = row # Store the row by the package name
# Check if the package exists in the CSV
if package_name not in packages:
print(f"Error: Unknown package '{package_name}'")
sys.exit(1)
# Download the package file from the URL
package_data = packages[package_name]
package_url = package_data["URL"]
package_file = wget.download(package_url, out=os.path.join(packages_dir, f"{package_name}.suspkg"))
# Extract the contents from the .suspkg file if needed
# Assuming .suspkg is a simple script for now, not a zipped file
# For example, you could move it directly:
print(f"Package '{package_name}' installed successfully at {package_file}")
# Clean up the tmp directory
os.system(f"rmdir /s /q {os.path.join(file_dir, "tmp")}")
if __name__ == "__main__":
match sys.argv[1]:
case "install":
if len(sys.argv) < 3:
print("Usage: vent install <package_name>")
sys.exit(1)
install_package(sys.argv[2])
case "update":
# Placeholder for update functionality
print("Update functionality is not implemented yet.")
case _:
print("Usage: vent.py install <package_name>")
sys.exit(1)