-
Notifications
You must be signed in to change notification settings - Fork 3
/
epimorph.py
executable file
·103 lines (76 loc) · 2.59 KB
/
epimorph.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /usr/bin/python
import sys
import os
import atexit
import re
import config.configmanager
from noumena.interface import *
from viro.engine import *
from phenom.cmdcenter import *
from common.runner import *
from common.log import *
set_log("EPIMORPH")
info("Starting Epimorphism")
# define & register exit handler
def exit():
debug("Exiting program")
# remove unclutter
os.system("killall unclutter")
atexit.register(exit)
# run unclutter to remove mouse pointer
os.system("unclutter -idle 0.25 -jitter 1 -root&")
# initialize env/state/profile/context/env
debug("Initializing state/profile/context/env")
if(len(sys.argv[1:]) != 0):
debug("with args %s" % (str(sys.argv[1:])))
# parse command line arguments
args={"application":"default", "app":{}, "env":{}, "context":{}, "profile":{}, "state":{}}
for arg in sys.argv[1:]:
# application
split = re.compile("=").split(arg)
if(len(split) == 1):
args["application"] = arg
continue
# parse val
val = split[1]
if(val[0] == '$'): val = eval(val[1:])
if(val == "True"): val = True
if(val == "False"): val = False
# create vars
split = re.compile("\.").split(split[0])
if(len(split) == 1): args["app"][split[0]] = val
else : args[split[0]][split[1]] = val
# create structures
app = configmanager.load_dict("app", args["application"], **args["app"])
env = configmanager.load_dict("environment", app.env, **args["env"])
context = configmanager.load_dict("context", app.context, **args["context"])
profile = configmanager.load_dict("profile", app.profile, **args["profile"])
state = configmanager.load_dict("state", app.state, **args["state"])
# encapsulated for asynchronous execution
def main():
info("Starting main loop")
# initialize & sync modules
debug("Initializing modules")
global interface, engine, cmdcenter
interface = Interface(context)
engine = Engine(profile)
cmdcenter = CmdCenter(env, state, interface, engine)
debug("Syncing modules")
interface.sync_cmd(cmdcenter)
engine.sync(interface.renderer)
# compile engine - CLEAN THIS
engine.compile({'ptxas_stats': profile.ptxas_stats, 'par_names':state.par_names, 'datamanager':cmdcenter.componentmanager.datamanager,
'splice':env.splice_components, 'state':state, 'cull_enabled':env.cull_enabled})
# start main loop
debug("Starting")
cmdcenter.start()
info("Main loop completed")
# clean objects
interface.__del__()
engine.__del__()
cmdcenter.__del__()
# start
def start():
async(main)
if(env.autostart):
start()