-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigbuilt.py
More file actions
58 lines (46 loc) · 1.48 KB
/
configbuilt.py
File metadata and controls
58 lines (46 loc) · 1.48 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
import os
import platform
import distutils.spawn
import requests
def is_tool(name):
return distutils.spawn.find_executable(name) is not None
if platform.system() == "Windows":
raise OSError("Don't run on Windows!")
run_folder = os.getcwd()
home = os.path.expanduser('~')
# get extra imports
if not os.path.exists(home + "/.configbuilt"):
raise OSError("Config directory does not exist!")
import angledat
os.system("rm angledat.py")
os.chdir(run_folder)
if os.path.exists("build.andat"):
data = angledat.read_dict("build.andat")
else:
raise OSError("Build data does not exist")
if not is_tool("wget"):
raise OSError("wget not installed")
try:
script = data["script to run"]
except:
raise OSError("No script to run given")
if not os.path.exists("downloads"):
os.system("mkdir downloads")
os.chdir("downloads")
for name in data:
if name == "script to run":
continue
else:
if not os.path.exists(name):
os.system("mkdir " + name)
else:
raise OSError("Package '" + name + "' has already been downloaded")
try:
response = requests.get(data[name])
os.system("wget " + data[name])
os.system("mv " + data[name].split("/")[-1] + " '" + name + "/" + data[name].split("/")[-1] + "'")
except requests.ConnectionError as exception:
print("Warning: Package '" + "' does not exist!")
os.remdir(name)
os.chdir("..")
os.system("bash " + script)