forked from jma127/pcu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·57 lines (38 loc) · 1.46 KB
/
main.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
import os
import helper
import parse
import globals
import pattern
import settings
# PCU main function
def main ():
# Read command line options
globals.probsettings = parse.parseopts()
# Initialize problem
helper.makedir(globals.sandboxdir)
if globals.getprob() is not None:
globals.probdir = os.path.join(globals.tmpdir, 'probs', globals.getprob())
globals.probsettingsfile = os.path.join(globals.probdir, 'probsettings.dat')
helper.makedir(globals.probdir)
# Merge dictionary with command line options
if globals.getprob() is not None:
opts = helper.readdict(globals.probsettingsfile) # Previous settings
for key in opts:
if key not in globals.probsettings or globals.probsettings[key] is None:
globals.probsettings[key] = opts[key]
# Assert that basic values are present in settings
if globals.getext() is None:
globals.probsettings['langext'] = settings.defaultlangext
if globals.getmode() is None:
globals.probsettings['mode'] = settings.defaultmode
# Execute command
print settings.bigdivider
globals.commands[globals.probsettings['command']]()
# Write new settings dict to file
if globals.getprob() is not None:
helper.writedict(globals.probsettingsfile, globals.probsettings)
# Clear sandbox directory
helper.deldir(globals.sandboxdir)
print settings.bigdivider
if __name__ == '__main__':
main()