-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
82 lines (65 loc) · 2.18 KB
/
config.py
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
import sys
import os
import subprocess
# Python version major.minor
PY_VER = "%d.%d" % (sys.version_info[0], sys.version_info[1])
VERSION = "1.0"
META_DIR = ".dolmades"
INST_DIR = "install"
SELF_PATH = os.path.dirname(os.path.realpath(sys.argv[0]))
HOME = os.path.expanduser('~')
DOLMADES_PATH = HOME + '/.dolmades'
REPO_PATH = DOLMADES_PATH + "/repo"
UDOCKER = SELF_PATH+"/udocker"
UDOCKERCMD_VERBOSE = UDOCKER+" --repo="+REPO_PATH
UDOCKERCMD_QUIET = UDOCKER+" --quiet --repo="+REPO_PATH
def INIT():
print("Preparing directories...")
untouched = True
if not os.path.exists(DOLMADES_PATH):
os.mkdir(DOLMADES_PATH, 0755)
untouched = False
try:
if (os.path.exists(REPO_PATH)):
os.rmdir(REPO_PATH)
untouched = False
except:
pass
if not os.path.exists(REPO_PATH):
cmd = UDOCKER+ " mkrepo "+REPO_PATH
print(cmd)
subprocess.call(cmd, shell=True, close_fds=True)
untouched = False
if (not os.path.exists(INST_PATH)):
os.mkdir(self.INST_PATH, 0755)
untouched = False
if (untouched):
print("found dolmade repo under " + REPO_PATH)
else:
print("initialized dolmade repo under " + REPO_PATH)
print("Preparing runtime...")
cmd = UDOCKERCMD_QUIET+" pull dolmades/runtime:"+VERSION
print(cmd)
print("Pulling dolmades runtime container...")
subprocess.call(cmd, shell=True, close_fds=True)
cmd = UDOCKERCMD_QUIET+" rm dolmades-runtime"
print(cmd)
subprocess.call(cmd, shell=True, close_fds=True)
cmd = UDOCKERCMD_QUIET+" create --name=dolmades-runtime dolmades/runtime:"+VERSION
print(cmd)
subprocess.call(cmd, shell=True, close_fds=True)
print("done")
try:
DESK_PATH = subprocess.check_output(['xdg-user-dir', 'DESKTOP']).strip()
except:
DESK_PATH = HOME + "/Desktop"
try:
DL_PATH = subprocess.check_output(['xdg-user-dir', 'DOWNLOAD']).strip()
except:
DL_PATH = HOME + "/Downloads"
try:
DOC_PATH = subprocess.check_output(['xdg-user-dir', 'DOCUMENTS']).strip()
except:
DOC_PATH = HOME + "/Documents"
INST_PATH = DOLMADES_PATH + "/" + INST_DIR
# TODO check if dirs exist and create them if neccessary!