diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-04-01 20:32:28 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-04-01 20:32:28 +0000 |
commit | 53fea983a90447865c429c2573bfb36cba179054 (patch) | |
tree | 42a0fa57a43103378144607d16e575e82071f7e1 /kpov_judge/tasks/nat_port_forward | |
parent | 2fe40ec78ce6ab3a8c2c5659713b7f947a5686fc (diff) |
added hints to task results
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@296 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/nat_port_forward')
-rw-r--r-- | kpov_judge/tasks/nat_port_forward/task.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py index a3fc740..0996d97 100644 --- a/kpov_judge/tasks/nat_port_forward/task.py +++ b/kpov_judge/tasks/nat_port_forward/task.py @@ -127,13 +127,14 @@ def gen_params(user_id, params_meta): def task_check(results, params): import re import cPickle - if results is None: - with open('bla.pickle') as f: - results = cPickle.load(f) - else: - with open('bla.pickle', 'w') as f: - cPickle.dump(results, f) + #if results is None: + # with open('bla.pickle') as f: + # results = cPickle.load(f) + #else: + # with open('bla.pickle', 'w') as f: + # cPickle.dump(results, f) score = 0 + hints = [] local_net = params['NET'][:params['NET'].rfind('.')] s = "default via ({}\\.[0-9]+)".format(re.escape(local_net)) res = re.search(s, results['route']) @@ -152,33 +153,33 @@ def task_check(results, params): if re.search(s, results['traceroute'], re.DOTALL): score += 1 else: - print (s, results['traceroute'],) + hints += [s + str(results['traceroute'])] if len(results['post_nc']) == 100: score += 1 else: - print (results['post_nc'], len(results['post_nc'])) + hints += [str(results['post_nc']) + str(len(results['post_nc']))] if results['nc_ret'] == (results['post_nc'] + '\n').replace('\n', '\r\n'): score += 1 else: - print (results['post_nc'], results['nc_ret'],) + hints += ['wrong nc'] s = "Connection refused" res = re.findall(s, results['nc_pre']) if len(res) >= 2: score += 3 else: - print (s, results['nc_pre'],) + hints += [s + str(results['nc_pre'])] s = "\r\n" if re.search(s, results['nc_post']): score += 1 else: - print (s, results['nc_post'],) + hints += [s + str(results['nc_post'])] rejected_count = int(results['pre_nc']) accepted_count = results['nc_ret'].count('\r\n') s = ".*verbose output suppressed.*listening on.*dropped by kernel.*" if re.match(s, results['tcpdump'], re.DOTALL): score += 1 else: - print (s, results['tcpdump'],) + hints += [s + str(results['tcpdump'])] res = re.findall("length .*\r\n", results['tcpdump']) total_len = 0 n_empty = 0 @@ -191,8 +192,8 @@ def task_check(results, params): if total_len == 101 and rejected_count <= n_empty: score += 1 else: - print (s, results['tcpdump'],) - return score + hints += [s + str(results['tcpdump'])] + return score, hints def prepare_disks(templates, params): # d = templates['simpleArbiterDhcp'] |