summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/set_motd
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 19:02:26 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 19:04:21 +0200
commitb5b35faea7f4205f353f57178ddc795b7dce5043 (patch)
treef8531a61d236ea0abc4e9dc80692abdc36c6579a /kpov_judge/tasks/set_motd
parent42076466e00aa066769050bb2e2b4d98e9cc4d20 (diff)
Refactor SSH testing code out of individual tasks
Catch SSH errors and report failures as hints. Also some cleanups and 2to3 fixes.
Diffstat (limited to 'kpov_judge/tasks/set_motd')
-rw-r--r--kpov_judge/tasks/set_motd/task.py15
1 files changed, 1 insertions, 14 deletions
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py
index 956f570..5f1b0b3 100644
--- a/kpov_judge/tasks/set_motd/task.py
+++ b/kpov_judge/tasks/set_motd/task.py
@@ -76,20 +76,7 @@ params_meta = {
def task(peer_ip, peer_user, peer_passwd, niz):
"Check whether ssh works"
- import collections
- from pexpect import pxssh
- results = collections.defaultdict(str)
- try:
- s = pxssh.pxssh(encoding='utf-8')
- s.login(peer_ip, peer_user, peer_passwd,
- original_prompt=r'{0}@.*:\~\$'.format(peer_user),
- auto_prompt_reset=False)
- results['ssh'] = True
- results['motd'] = s.before
- s.logout()
- except Exception as ex:
- results['ssh'] = str(ex)
- return results
+ return kpov_util.ssh_test(peer_ip, peer_user, peer_passwd)
def gen_params(user_id, params_meta):
return kpov_util.default_gen(user_id, params_meta)