diff options
author | Prabhu Ramachandran | 2013-07-03 04:26:40 -0700 |
---|---|---|
committer | Prabhu Ramachandran | 2013-07-03 04:26:40 -0700 |
commit | ee64cfe58c42540d0736cc32d3acd36ab7a6d31d (patch) | |
tree | 6104cea3d6682e8d101da7f44ad645e7e00fc4f1 /testapp/exam/xmlrpc_clients.py | |
parent | fe868c043487af8ea390165325309ad29daacc8e (diff) | |
parent | 7b18a329a2692d3f85fbe71fa99ceee9838b85c8 (diff) | |
download | online_test-ee64cfe58c42540d0736cc32d3acd36ab7a6d31d.tar.gz online_test-ee64cfe58c42540d0736cc32d3acd36ab7a6d31d.tar.bz2 online_test-ee64cfe58c42540d0736cc32d3acd36ab7a6d31d.zip |
Merge pull request #12 from prathamesh920/fresh_C_Cpp
Fresh c cpp
Diffstat (limited to 'testapp/exam/xmlrpc_clients.py')
-rw-r--r-- | testapp/exam/xmlrpc_clients.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 817e37d..b846212 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -9,19 +9,24 @@ from settings import SERVER_PORTS, SERVER_POOL_PORT class ConnectionError(Exception): pass -################################################################################ +############################################################################### # `CodeServerProxy` class. -################################################################################ +############################################################################### + + class CodeServerProxy(object): """A class that manages accesing the farm of Python servers and making calls to them such that no one XMLRPC server is overloaded. """ def __init__(self): - pool_url = 'http://localhost:%d'%(SERVER_POOL_PORT) + pool_url = 'http://localhost:%d' % (SERVER_POOL_PORT) self.pool_server = ServerProxy(pool_url) self.methods = {"python": 'run_python_code', - "bash": 'run_bash_code'} - + "bash": 'run_bash_code', + "C": "run_c_code", + "C++": "run_cplus_code", + } + def run_code(self, answer, test_code, user_dir, language): """Tests given code (`answer`) with the `test_code` supplied. If the optional `in_dir` keyword argument is supplied it changes the directory @@ -68,11 +73,10 @@ class CodeServerProxy(object): else: done = True if not done: - raise ConnectionError("Couldn't connect to a server!") - proxy = ServerProxy('http://localhost:%d'%port) + raise ConnectionError("Couldn't connect to a server!") + proxy = ServerProxy('http://localhost:%d' % port) return proxy # views.py calls this Python server which forwards the request to one # of the running servers. code_server = CodeServerProxy() - |