diff options
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.py | 37 |
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) |