summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/copy_rename_20_files_tail_env
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2016-10-01 21:46:34 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2016-10-01 21:46:34 +0000
commitfa8934667ad8eae30c81081bbaa868b227c119ed (patch)
treed2a69178cfb693c0da0ffbefaff2da70a64f52f5 /kpov_judge/tasks/copy_rename_20_files_tail_env
parent7210b74d6241a4264532aaaa2e1d771eaca4e073 (diff)
added a global_params parameter to prepare_disks so that the task_name, username and task_url are pre-entered on the arbiters
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@351 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env')
-rw-r--r--kpov_judge/tasks/copy_rename_20_files_tail_env/task.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
index d020a7a..37886c6 100644
--- a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
+++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py
@@ -115,7 +115,7 @@ params_meta = {
}
def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string, curl_fname, wc_dirname):
- import pxssh
+ from pexpect import pxssh
import os
# TODO: (polz) this has to be changed! Get a move on!
#
@@ -344,32 +344,32 @@ def task_check(results, params):
hints += ["wrong line count"]
return score, hints
-def prepare_disks(templates, params):
+def prepare_disks(templates, task_params, global_params):
# d = templates['simpleArbiterDhcp']
import random
#print "Haha!"
#print params
#print templates
d = templates['malishell']
- r = random.Random(params['file_creator_random_seed'])
+ r = random.Random(task_params['file_creator_random_seed'])
# rename
- d.mkdir(params['file_rename_dirname'])
- d.chown(1000, 1000, params['file_rename_dirname'])
+ d.mkdir(task_params['file_rename_dirname'])
+ d.chown(1000, 1000, task_params['file_rename_dirname'])
for i in xrange(20):
- fname = params['file_rename_dirname'] + '/' + "".join(
+ fname = task_params['file_rename_dirname'] + '/' + "".join(
[r.choice("-abcdefghijk") for j in xrange(8)])
d.touch(fname)
d.chown(1000, 1000, fname)
# mv ukaz
- d.mkdir(params['mv_src_dir'])
- d.chown(1000, 1000, params['mv_src_dir'])
+ d.mkdir(task_params['mv_src_dir'])
+ d.chown(1000, 1000, task_params['mv_src_dir'])
for i in xrange(40):
- fname = params['mv_src_dir'] + '/' +"".join(
+ fname = task_params['mv_src_dir'] + '/' +"".join(
[r.choice("123456789abcdefghijk") for j in xrange(8)])
d.touch(fname)
d.chown(1000, 1000, fname)
- d.mkdir(params['mv_dst_dir'])
- d.chown(1000, 1000, params['mv_dst_dir'])
+ d.mkdir(task_params['mv_dst_dir'])
+ d.chown(1000, 1000, task_params['mv_dst_dir'])
# grep mama
# mama fnames
d.mkdir('/home/student/grep_test_dir')
@@ -391,20 +391,21 @@ def prepare_disks(templates, params):
d.ln_sf("mali zeleni", "/home/student/grep_test_dir/" + "".join(
[ r.choice("123456789abcdefghijk") for j in xrange(8)]))
# sledenje syslog
- spammer_source = "#!/bin/sh\n" + int(params['syslog_n_zmeda']) * "logger zmeda\n"
+ spammer_source = "#!/bin/sh\n" + int(task_params['syslog_n_zmeda']) * "logger zmeda\n"
d.write("/usr/local/bin/syslog_spammer", spammer_source)
d.chmod(0775, "/usr/local/bin/syslog_spammer")
# curl
- l1 = ['images'] * int(params['curl_n_images'])
+ l1 = ['images'] * int(task_params['curl_n_images'])
l2 = ['imeges'] * r.randint(30, 100)
lx = l1 + l2
r.shuffle(lx)
- d.write("/var/www/html/{}".format(params['curl_fname']), ''.join(lx))
+ d.write("/var/www/html/{}".format(task_params['curl_fname']), ''.join(lx))
# wc
- lx = ['\n']*int(params['wc_n_lines'])
+ lx = ['\n']*int(task_params['wc_n_lines'])
lx += ['a', 'b', 'c', 'repa', 'in', 'krompir',
'raus', 'e', 'patacis'] * r.randint(50, 150)
r.shuffle(lx)
- d.mkdir(params['wc_dirname'])
- d.chown(1000, 1000, params['wc_dirname'])
- d.write("{}".format(os.path.join(params['wc_dirname'], 'count.txt')), "".join(lx))
+ d.mkdir(task_params['wc_dirname'])
+ d.chown(1000, 1000, task_params['wc_dirname'])
+ d.write("{}".format(os.path.join(task_params['wc_dirname'], 'count.txt')), "".join(lx))
+ write_default_config(templates['simpleArbiter'], global_params)