summaryrefslogtreecommitdiff
path: root/testapp/exam/code_server.py
diff options
context:
space:
mode:
authorankitjavalkar2015-04-26 21:13:53 +0530
committerankitjavalkar2015-04-26 21:13:53 +0530
commit18df6d88a2e1a9dfe7d05ca97b2d69ff0569e088 (patch)
tree3a12a2497964c26f3750d81cf04e7953e795514a /testapp/exam/code_server.py
parent8664a766406d6acf0d6a1688948153c407ea27f2 (diff)
downloadonline_test-18df6d88a2e1a9dfe7d05ca97b2d69ff0569e088.tar.gz
online_test-18df6d88a2e1a9dfe7d05ca97b2d69ff0569e088.tar.bz2
online_test-18df6d88a2e1a9dfe7d05ca97b2d69ff0569e088.zip
Make PEP8 consistent
Diffstat (limited to 'testapp/exam/code_server.py')
-rwxr-xr-xtestapp/exam/code_server.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/testapp/exam/code_server.py b/testapp/exam/code_server.py
index 111562a..697b131 100755
--- a/testapp/exam/code_server.py
+++ b/testapp/exam/code_server.py
@@ -40,9 +40,11 @@ from evaluate_java_code import EvaluateJavaCode
from evaluate_scilab_code import EvaluateScilabCode
from evaluate_bash_code import EvaluateBashCode
+
MY_DIR = abspath(dirname(__file__))
-## Private Protocol ##########
+
+# Private Protocol ##########
def run_as_nobody():
"""Runs the current process as nobody."""
# Set the effective uid and to that of nobody.
@@ -50,6 +52,7 @@ def run_as_nobody():
os.setegid(nobody.pw_gid)
os.seteuid(nobody.pw_uid)
+
###############################################################################
# `CodeServer` class.
###############################################################################
@@ -61,10 +64,13 @@ class CodeServer(object):
self.port = port
self.queue = queue
- ## Public Protocol ##########
+ # Public Protocol ##########
def check_code(self, language, json_data, in_dir=None):
- """Calls relevant EvaluateCode class based on language to check the answer code"""
- evaluate_code_instance = self.create_class_instance(language, json_data, in_dir)
+ """Calls relevant EvaluateCode class based on language to check the
+ answer code
+ """
+ evaluate_code_instance = self.create_class_instance(language,
+ json_data, in_dir)
result = evaluate_code_instance.run_code()
@@ -73,14 +79,14 @@ class CodeServer(object):
return json.dumps(result)
- ## Public Protocol ##########
+ # Public Protocol ##########
def create_class_instance(self, language, json_data, in_dir):
"""Create instance of relevant EvaluateCode class based on language"""
cls = registry.get_class(language)
instance = cls.from_json(language, json_data, in_dir)
return instance
- ## Public Protocol ##########
+ # Public Protocol ##########
def run(self):
"""Run XMLRPC server, serving our methods."""
server = SimpleXMLRPCServer(("localhost", self.port))
@@ -120,7 +126,7 @@ class ServerPool(object):
p.start()
self.servers = servers
- ## Public Protocol ##########
+ # Public Protocol ##########
def get_server_port(self):
"""Get available server port from ones in the pool. This will block