1 import sys
2
3 from DefaultSettings import *
4
5
6 import os
7 if "TEES_SETTINGS" in os.environ:
8 import imp
9 pathname = os.environ["TEES_SETTINGS"]
10 imp.load_source("TEESLocalSettings", pathname)
11
12 tempURL = URL
13 tempEVALUATOR = EVALUATOR
14
15 exec "from TEESLocalSettings import *"
16
17 tempURL.update(URL)
18 URL = tempURL
19 tempEVALUATOR.update(EVALUATOR)
20 EVALUATOR = tempEVALUATOR
21
22 -def setLocal(variable, value, setVariable=True):
23
24 if not setVariable:
25 print >> sys.stderr, "Remember to add local setting", str(variable) + "=\"" + str(value) + "\""
26 return
27 assert "TEES_SETTINGS" in os.environ
28 print >> sys.stderr, "Adding local setting", str(variable) + "=" + str(value),
29
30 exec (variable + " = '" + str(value) + "'") in globals()
31
32 f = open(os.environ["TEES_SETTINGS"], "rt")
33 lines = f.readlines()
34 f.close()
35
36
37 found = False
38 for i in range(len(lines)):
39 if lines[i].strip() != "" and lines[i].strip()[0] == "#":
40 continue
41 if lines[i].split("=")[0].strip() == variable:
42 lines[i] = variable + " = '" + str(value) + "'\n"
43 print >> sys.stderr, "(updated existing value)"
44 found = True
45
46 if not found:
47 lines.append(variable + " = '" + str(value) + "'\n")
48 print >> sys.stderr, "(added variable)"
49
50
51 f = open(os.environ["TEES_SETTINGS"], "wt")
52 for line in lines:
53 f.write(line)
54 f.close()
55