summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/copy_rename_100_files
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-06 23:35:00 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 00:13:58 +0200
commite33085889f26c76587fdab2ad600ed336dc028b5 (patch)
tree980dd39519bc355aeb17572affcae58d3a0966cd /kpov_judge/tasks/copy_rename_100_files
parent43d7ef057b4ae752a60b947e523b3a56782bf5cd (diff)
Improve ssh error reporting in some tasks
Diffstat (limited to 'kpov_judge/tasks/copy_rename_100_files')
-rw-r--r--kpov_judge/tasks/copy_rename_100_files/task.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/kpov_judge/tasks/copy_rename_100_files/task.py b/kpov_judge/tasks/copy_rename_100_files/task.py
index 9ad4d66..c658d27 100644
--- a/kpov_judge/tasks/copy_rename_100_files/task.py
+++ b/kpov_judge/tasks/copy_rename_100_files/task.py
@@ -73,16 +73,19 @@ params_meta = {
}
def task(host, folder):
+ import collections
from pexpect import pxssh
-
- # ideally, this would be done using a SFTP client instead of pxssh
- target = pxssh.pxssh()
- target.login(host, 'test', 'test')
- results = {
- 'files': target.run('ls -1').split('\n'), # XXX: file may have newlines
- 'contents': target.run("cat *"), # XXX: may include other files in $HOME
- }
- target.logout()
+ results = collections.defaultdict(str)
+ try:
+ # ideally, this would be done using a SFTP client instead of pxssh
+ s = pxssh.pxssh(encoding='utf-8')
+ s.login(host, 'test', 'test')
+ results['ssh'] = True
+ results['files'] = s.run('ls -1').split('\n'), # XXX: file may have newlines
+ results['contents'] = s.run('cat *'), # XXX: may include other files in $HOME
+ s.logout()
+ except Exception as ex:
+ results['ssh'] = str(ex)
return results
def gen_params(user_id, params_meta):