-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.py
More file actions
executable file
·108 lines (83 loc) · 2.94 KB
/
installer.py
File metadata and controls
executable file
·108 lines (83 loc) · 2.94 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
97
98
99
100
101
102
103
104
105
106
107
108
#! /usr/bin/python3
import os, subprocess
from shutil import copy, copytree, rmtree
import sys, argparse
basePath = os.path.expanduser("~/.notes_cfg")
installPath = os.path.expanduser("~/.notes_cfg/exe")
notesDirPath = os.path.expanduser("~/.notes")
cfgPath = basePath + "/config"
def parse_args(arglist):
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--path')
parser.add_argument('-d', '--debug', action="store_true")
parser.add_argument('-c', '--clean', action="store_true")
parser.add_argument('-l', '--loglevel', default=-1) # Store -1 so we make a prod build
return parser.parse_args(arglist)
args = parse_args(sys.argv[1:])
call_path = os.path.dirname(os.path.abspath(sys.argv[0]));
if args.path:
notesDirPath = os.path.expanduser(args.path)
if not os.path.exists(notesDirPath):
os.mkdir(notesDirPath)
if not os.path.exists(notesDirPath + "/.flat_notes"):
os.mkdir(notesDirPath + "/.flat_notes")
if not os.path.exists(notesDirPath + "/.assets"):
os.mkdir(notesDirPath + "/.assets")
if not os.path.exists(basePath):
os.mkdir(basePath)
if not os.path.exists(installPath):
os.mkdir(installPath)
else:
rmtree(installPath)
print("Cleaned old installation")
if not os.path.exists(cfgPath):
os.mkdir(cfgPath)
else:
rmtree(cfgPath)
print("Cleaned old configuration")
print("Necessary Directories Created")
# ---------------------------------------------------------------------------------------------
# Install the directory server
copytree(call_path + "/dirServer", installPath + "/dirServer")
print("Installed Local Directory Server")
# Install the search library
copytree(call_path + "/searchLib", installPath + "/searchLib")
print("Installed python searching library")
# Install the config library
copytree(call_path + "/configLib", installPath + "/configLib")
print("Installed python configuration library")
# Install config files
copytree(call_path + "/config", cfgPath)
print("Installed configuration files")
# Remake the file
cwd = os.getcwd()
os.chdir(call_path + "/preprocessor")
loglevel = int(args.loglevel)
if args.clean:
subprocess.run(["make", "clean"])
if args.debug or loglevel >= 4:
subprocess.run(["make", "debug"])
elif loglevel == 0:
subprocess.run(["make", "silent"])
elif loglevel == 1:
subprocess.run(["make", "error"])
elif loglevel == 2:
subprocess.run(["make", "warn"])
elif loglevel == 3:
subprocess.run(["make", "info"])
else:
subprocess.run(["make", "prod"])
print("Remade Preprocessor")
os.chdir(cwd)
# Install the preprocessor
copy(call_path + "/preprocessor/preprocessor", installPath + "/preprocessor")
print("Installed Preprocessor")
# Install the UI
copytree(call_path + "/noteRenderer/build", installPath + "/UI")
print("Installed UI")
# Install the cli driver
copytree(call_path + "/driver", installPath + "/driver")
os.rename(installPath + "/driver/driver.py", installPath + "/driver/notes")
print("Installed CLI")
# Install the gitignore
copy(call_path + "/notes_gitignore", notesDirPath + "/.gitignore")