summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/set_motd
diff options
context:
space:
mode:
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):