~vomun-developers/anonplus/vomun-trunk

« back to all changes in this revision

Viewing changes to src/libs/morado/morado.py

  • Committer: AJ00200
  • Date: 2011-11-26 00:03:57 UTC
  • Revision ID: git-v1:f4f4352eb338a5f57a5a92e4bf23bec36d298d13
Blocks we receive are now stored in ~/.vomun/blocks.json. libs.globals and libs.config are now used directly after importing libs; they are set in libs/__init__.py now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
path =  os.getcwd()
11
11
sys.path.append(path)
12
12
 
 
13
import libs
13
14
import libs.threadmanager
14
 
import libs.globals
15
15
import libs.morado.functions
16
16
 
17
17
def errorfunc(*args):
83
83
        args = request["args"]
84
84
 
85
85
        try:
86
 
            ret =  libs.globals.global_vars["apifunctions"][function](*args)
 
86
            ret =  libs.globals['apifunctions'][function](*args)
87
87
            if isinstance(ret, dict):
88
88
                return ret
89
89
            else:
91
91
                                            # make a dict
92
92
 
93
93
        except Exception as ex:
94
 
            #print libs.globals.global_vars["apifunctions"]
 
94
            #print libs.globals["apifunctions"]
95
95
            ex = traceback.format_exc()
96
96
            #print ex
97
97
            return {"error2": ex}
134
134
class APIServerThead(libs.threadmanager.Thread):
135
135
 
136
136
    def run(self):
137
 
        libs.globals.global_vars["apiserver"] = APIServer('localhost', 3451)
 
137
        libs.globals['apiserver'] = APIServer('localhost', 3451)
138
138
        print('API-server running on port 3451 : Started')
139
139
        while not self._stop.isSet():
140
140
            asyncore.loop(timeout = 5, count = 1)
143
143
    '''Start the API interface. Create the Server object and the listener
144
144
    we use to listen for events from this interface.
145
145
    '''
146
 
    """libs.globals.global_vars["apiserver"] = APIServer('localhost', 9999)
147
 
    libs.threadmanager.register(libs.globals.global_vars["apiserver"])
148
 
    libs.globals.global_vars["apiserver"].start()"""
 
146
    """libs.globals['apiserver'] = APIServer('localhost', 9999)
 
147
    libs.threadmanager.register(libs.globals['apiserver'])
 
148
    libs.globals['apiserver'].start()"""
149
149
    #api.functions.register()
150
 
    libs.globals.global_vars["APIServerThread"] = APIServerThead()
151
 
    libs.threadmanager.register(libs.globals.global_vars["APIServerThread"])
152
 
    libs.globals.global_vars["APIServerThread"].start()
 
150
    libs.globals['APIServerThread'] = APIServerThead()
 
151
    libs.threadmanager.register(libs.globals['APIServerThread'])
 
152
    libs.globals['APIServerThread'].start()
153
153
 
154
154
if __name__ == "__main__":
155
155
    start()