summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/copy_rename_100_files/task.py
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/tasks/copy_rename_100_files/task.py')
-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):