diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-28 14:12:13 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-28 14:12:13 +0000 |
commit | 677e3ac2a4687e15f40dbc060f1bbb96b01d2c58 (patch) | |
tree | dbba338cba9e8bbb198b45ffb7da1503cb683199 /kpov_judge | |
parent | 6a4a5a588e247d9a51425ebe62595e043a84b0d2 (diff) |
Fixed, tested set_motd task(), task_check()
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@247 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r-- | kpov_judge/tasks/set_motd/task.py | 7 | ||||
-rwxr-xr-x | kpov_judge/test_task.py | 15 |
2 files changed, 13 insertions, 9 deletions
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py index c8b42e3..cfea848 100644 --- a/kpov_judge/tasks/set_motd/task.py +++ b/kpov_judge/tasks/set_motd/task.py @@ -78,10 +78,11 @@ def task(peer_ip, peer_user, peer_passwd, niz): 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) - s.prompt() + # 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. + # 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 @@ -92,6 +93,8 @@ def gen_params(user_id, params_meta): def task_check(results, params): #print task_url + #print params + #print results niz = params['niz'] score = 0 if (results['motd'].find(niz) > -1): diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index b59aebc..bf20f1f 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -175,9 +175,9 @@ if __name__ == '__main__': task_params = params['task_params'][params['task_name']] if basic_args.generate_params: #prejema lahko samo stringe in ne številk (potrebno je str(int) - print ("params before: {} {}".format(params, task_params)) + # print ("params before: {} {}".format(params, task_params)) task_params.update(gen_params(params['username'], task_params_meta)) - print ("params after: {} {}".format(params, task_params)) + # print ("params after: {} {}".format(params, task_params)) if task_url.startswith('http'): req = urllib2.Request("{task_url}/{task_name}/params.json".format(**params)) web_task_params = json.load(urllib2.urlopen(req)) @@ -189,8 +189,8 @@ if __name__ == '__main__': if k in args and args[k] is not None: task_params[k] = args[k] if dialog is not None: - print(task_params) task_params = get_params_dialog(task_params, task_params_meta, dialog=dialog, language = params['language']) + # print(task_params) if basic_args.help: # params_argparser.print_help() print(params_argparser.format_help()) @@ -200,6 +200,10 @@ if __name__ == '__main__': for k in inspect.getargs(task.func_code)[0]: public_params[k] = task_params[k] params['task_params'][params['task_name']] = task_params + # save parameters for the next run + with open(basic_args.params_file, 'w') as f: + # print "dumping", params + yaml.dump(params, f) try: task_result = task(**public_params) # run task.task_check() @@ -208,11 +212,8 @@ if __name__ == '__main__': print(e) try: result = task_check(task_result, task_params) + print result except Exception as e: print("Error running task_check(results, params):") print(e) - # print results - # save parameters for the next run - with open(basic_args.params_file, 'w') as f: - yaml.dump(params, f) |