-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
·60 lines (45 loc) · 1.65 KB
/
Copy pathinstall.py
File metadata and controls
executable file
·60 lines (45 loc) · 1.65 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
#!/usr/bin/env python3
#install.py
#install script - this should work out of the box if the above path is right
############################################################################
import os,os.path,sys
if len(sys.argv) < 2 :
print("usage: %s <username> "%sys.argv[0])
sys.exit(1)
vals = {}
vals["USER"] = sys.argv[1]
vals["PATH"] = os.getcwd()+"/";
vals["HOME"] = os.path.expanduser("~") #os.environ["HOME"]+"/"
vals["CYGWIN"] = ('0','1')[os.popen("uname").readline().find("CYGWIN") != -1]
globals().update(vals)
if os.path.exists("settings.pl") :
print("ERROR: settings.pl already exists")
sys.exit(1)
infile = open("settings.pl.template",'r')
outfile = open("settings.pl",'w')
symlink = os.path.join(HOME,".tagtimerc")
target = os.path.join(PATH,"settings.pl")
def getVar(line) :
fields = line.split("__")
if len(fields) == 3 :
return fields[1]
return None
for lineNum,line in enumerate(infile) :
var = getVar(line)
if var :
if not var in vals or not vals[var] :
print("*** WARNING *** no value defined for __%s__"%var,"on line",lineNum,"of settings.pl.template")
print("*** you must manually set this parameter in settings.pl for tagtime to function properly")
else :
pat = "__%s__"%var
line = line.replace(pat,vals[var])
pos = line.find(";")+1
line = line[:pos].ljust(40)+line[pos:]
outfile.write(line)
if os.path.isdir(symlink) :
print("ERROR - directory exists: ",symlink)
sys.exit(1)
if os.path.islink(symlink) or os.path.isfile(symlink) :
os.remove(symlink)
os.system("ln -s %s %s"%(target,symlink))
print("Done! Take a look at settings.pl to see if it looks ok...")