summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/custom_rdate
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2016-12-29 23:43:31 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2016-12-29 23:43:31 +0000
commite11077772bf32f25613f4f559feee8c963ea5dda (patch)
treee770210a5e750cf323c77ffc928bdc35115feb14 /kpov_judge/tasks/custom_rdate
parent110ab9c64c408dce2345f134989f5d15bcce42ae (diff)
Fixes to multiple tasks
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@377 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/custom_rdate')
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
index c278792..867e037 100644
--- a/kpov_judge/tasks/custom_rdate/task.py
+++ b/kpov_judge/tasks/custom_rdate/task.py
@@ -69,9 +69,9 @@ networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
# Tu sem dolocil parametre
params_meta = {
- 'RDATE_OFFSET':{'descriptions': {'si': 'Napaka v času pri rdate'}, 'w': False, 'public': False, 'type': 'integer', 'generated': True},
- 'PROGRAM_FILENAME':{'descriptions': {'si': 'Ime programa'}, 'w': False, 'public': True, 'type': 'integer', 'generated': True},
- 'IP_RDATECLIENT':{'descriptions': {'si': 'IP rdateClient'}, 'w': True, 'public': False, 'type': 'IP', 'generated': False},
+ 'RDATE_OFFSET':{'descriptions': {'si': u'Napaka v času pri rdate', 'en': 'Timekeeping error for rdate'}, 'w': False, 'public': False, 'type': 'integer', 'generated': True},
+ 'PROGRAM_FILENAME':{'descriptions': {'si': u'Ime programa', 'en': 'program filename'}, 'w': False, 'public': True, 'type': 'integer', 'generated': True},
+ 'IP_RDATECLIENT':{'descriptions': {'si': u'IP rdateClient', "en": "rdateClient's IP"}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
}
def task(IP_RDATECLIENT, PROGRAM_FILENAME):
@@ -80,6 +80,7 @@ def task(IP_RDATECLIENT, PROGRAM_FILENAME):
from paramiko import SSHClient
import random
import struct
+ import base64
results = dict()
peer_user = 'test'
peer_passwd = 'test'
@@ -94,7 +95,7 @@ def task(IP_RDATECLIENT, PROGRAM_FILENAME):
'~/{}'.format(PROGRAM_FILENAME))
data = struct.pack("!I", r.randint(0, 2**32))
stdin.write(data)
- results['in_' + str(i)] = data
+ results['in_' + str(i)] = base64.encodestring(data)
results['out_' + str(i)] = stdout.read()
stdin, stdout, stderr = client.exec_command(
'date -u +"%s"')
@@ -122,16 +123,19 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import random
import struct
+ import base64
# print results
r = random.Random(params['PROGRAM_FILENAME'])
score = 0.0
hints = []
for i in xrange(10):
- data = results['in_' + str(i)]
- if data != struct.pack("!I", r.randint(0, 2**32)):
+ data = base64.decodestring(results['in_' + str(i)])
+ x = struct.pack("!I", r.randint(0, 2**32))
+ if data != x:
+ hints += ["data: " + str((data,)) + " != " + str((x,))]
break
res = results['out_' + str(i)]
- if str(struct.unpack("!I", data)[0]) == res.strip():
+ if str(struct.unpack("!i", data)[0]) == res.strip():
score += 0.5
else:
hints += ["wrong convert"]