summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/set_motd
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 20:21:31 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 20:21:31 +0200
commit80f050080ce11c6a0cce67c9b0281c09702b00d6 (patch)
treeb486e1f6342bc757dda87df4856084f652895791 /kpov_judge/tasks/set_motd
parent43d7ef057b4ae752a60b947e523b3a56782bf5cd (diff)
parentdbf585c2a59dbcb7f6d803d5756826b562cd7f43 (diff)
Merge branch 'fix-tasks'
Fixes pexpect usage in most tasks. Several other cleanups and minor refactoring.
Diffstat (limited to 'kpov_judge/tasks/set_motd')
-rw-r--r--kpov_judge/tasks/set_motd/task.py41
1 files changed, 12 insertions, 29 deletions
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py
index eadcca7..f2b65fb 100644
--- a/kpov_judge/tasks/set_motd/task.py
+++ b/kpov_judge/tasks/set_motd/task.py
@@ -1,9 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# bson.son.SON an
-# kpov_random_helpers should be imported by add_assignment.py
-# OrderedDict = SON
+# kpov_util should be imported by add_assignment.py
instructions = {
"si":"""
@@ -76,35 +71,23 @@ params_meta = {
def task(peer_ip, peer_user, peer_passwd, niz):
"Check whether ssh works"
- from pexpect import pxssh
- import pexpect
- # return {"hello": 'kitty'}
- results = dict()
- s = pxssh.pxssh()
- #TODO (polz): tole bi utegnilo delovati http://pexpect.sourceforge.net/pxssh.html. Testirajte
- s.login (peer_ip, peer_user, peer_passwd, original_prompt=r'{0}@.*:\~\$'.format(peer_user),auto_prompt_reset=False)
- # print s.before
- # s.prompt()
- #Ce na serverju iz datoteke /var/run/motd.dynamic pobrisemo znak '#' bi moralo delovati.
-
- # temp = s.before # print everything before the prompt.
- #TODO (polz): tole ni pravi pristop. Problem je bil v tem, da pxssh ni prav zaznal, kdaj je prijavljen. Glej link zgoraj.
- results['motd'] = s.before # print everything before the prompt.
- return results
- #
-
+ return kpov_util.ssh_test(peer_ip, peer_user, peer_passwd)
+
def gen_params(user_id, params_meta):
- return kpov_random_helpers.default_gen(user_id, params_meta)
+ return kpov_util.default_gen(user_id, params_meta)
def task_check(results, params):
- #print task_url
- #print params
- #print results
niz = params['niz']
score = 0
hints = []
- if (results['motd'].find(niz) > -1):
- score += 10
+ if results['ssh'] is True:
+ score += 2
+ else:
+ hints += ['ssh failed: ' + results['ssh']]
+ if niz in results['motd']:
+ score += 8
+ else:
+ hints += ['wrong motd:\n' + results['motd'] + '\n']
return score, hints
def prepare_disks(templates, task_params, global_params):