diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-04-09 18:00:43 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-04-09 18:00:43 +0000 |
commit | d3e8f24b4da66059058627168f3f71eaf7626a93 (patch) | |
tree | cf2f524d42af38ef0b5ea556f8bc41df4bf07779 /kpov_judge/tasks/copy_rename_20_files_tail_env | |
parent | 54c45f7e5e85a088eeb301fb3677f9c743cccbb5 (diff) |
fixed disk template names
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@298 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.py | 75 |
1 files changed, 46 insertions, 29 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 44e9f87..d020a7a 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 @@ -8,12 +8,14 @@ instructions = { Prijavi se na sistem kot uporabnik student z geslom vaje. V domači mapi najdeš imenik {file_rename_dirname} z 20 datotekami. - Preimenuj vse datoteke tako, da zamenjaš minuse s podčrtaji - - Napiši čim krajši ukaz v bash, ki vse datoteke iz imenika {mv_src_dir} - podanega imenika premakne v imenik {mv_dst_dir}. Spravi ga v - /home/student/mv_ukaz. Pazi, da bodo ob testiranju v izvornem imeniku iste - datoteke, kot so bile, ko je bila virtualka nova, ciljni imenik pa bo prazen. - - Napiši ukaz, ki s pomočjo ukaza grep v datoteko ~/mama.txt izpiše vse - navadne (ne skrite) datoteke v trenutnem imeniku, ki vsebujejo niz "mama", + - Napiši najkrajši ukaz v bash, ki vse datoteke iz imenika {mv_src_dir} + premakne v imenik {mv_dst_dir}. Ukaz spravi v + /home/student/mv_ukaz. Pazi, da bodo ob testiranju v izvornem imeniku ISTE + datoteke, kot so bile, ko je bila virtualka nova, ciljni imenik pa bo + prazen. To pomeni, da boste verjetno morali po vsakem testiranju datoteke + premakniti nazaj. Za krajšanje ukaza lahko izkoristite imeni imenikov. + - Napiši ukaz, ki s pomočjo ukaza grep v datoteko ~/mama.txt izpiše imena vseh + navadnih (ne skritih) datotek v trenutnem imeniku, ki vsebujejo niz "mama", v datoteko ~/napake.txt pa izpiše vse morebitne napake (npr. to, da so nekateri objekti v trenutnem imeniku dejansko imeniki ali napačne simbolične povezave). Ukaz spravite v datoteko /home/student/mama_ukaz. @@ -37,12 +39,17 @@ In your home folder you will find a directory called {file_rename_dirname} underscores - Find the shortest command for copying all the files located in {mv_src_dir} into the folder {mv_dst_dir}. - Create a shell script /home/student/mv_ukaz containing this commant - - Specify the shortest command which will, using the grep command, - write all normal (not hidden) files containing a string "mama" located - in working directory (pwd) into the file ~/mama.txt while writing errors such as - files in current directory being folders or symbolic links in the file called - "napake.txt" + Create a shell script /home/student/mv_ukaz containing this command. + Before running test_task, make sure {mv_src_dir} contains the same + files as when you downloaded your virtual disk. This probably means + that you will have to move the files back from {mv_dst_dir} to + {mv_src_dir} after each test. You can use the directory na + - Come up with a command or sequence of commands in bash which will, + using grep, write the names all normal (not hidden) files which contain + the string "mama" and are located in the working directory (pwd) + into the file ~/mama.txt while writing errors such as files in current + directory being folders or symbolic links in the file called + "napake.txt". Write this command - Write a program (which may be a shell script) that will track the contents of /var/log/syslog for 5s. Every time an entry containing the string "zmeda" appears in the syslog, in syslog, the script should output "imam ga". @@ -70,7 +77,7 @@ computers = { # 'parts': [],# no parts, no mounting. #} ], - 'network_interfaces': [{'network': 'net1'}], + 'network_interfaces': [{'network': 'test-net'}], 'flavor': 'm1.tiny', 'config_drive': False @@ -85,13 +92,13 @@ computers = { # 'parts': [{'dev': 'b1', 'path': '/cdrom'}], #}, ], - 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], + 'network_interfaces': [{'network': 'test-net'}], 'flavor': 'm1.tiny', 'config_drive': False } } -networks = { 'net1': {'public': False}, 'test-net': {'public': True} } +networks = {'test-net': {'public': True} } params_meta = { 'IP_malishell': {'descriptions': {'si': 'Naslov malishell'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False}, @@ -170,7 +177,10 @@ def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_strin conn.sendline('cowsay "{}"'.format(cowsay_string)) conn.prompt() results['cowsay'] = conn.before - results['curl_env'] = os.environ['images'] + try: + results['curl_env'] = os.environ['images'] + except: + results['curl_env'] = '' conn.sendline('cat {}/count.txt'.format(wc_dirname)) conn.prompt() results['wc_origfile'] = conn.before @@ -239,17 +249,20 @@ def task_check(results, params): hints += ["wrong dash rename"] # premakni datoteke s cim krajsim ukazom fnames = [] - for i in xrange(40): - fnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)])) - task2_re = re.search( - r"-rw[x-][r-][w-][x-][r-][w-][x-] \d* student student (\d*) .*mv_ukaz", - results['mv_ls_size']) - mv_ls_size = int(task2_re.group(1)) - task2_ok = mv_ls_size < 15 and mv_ls_size > 2 + try: + for i in xrange(40): + fnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)])) + task2_re = re.search( + r"-rw[x-][r-][w-][x-][r-][w-][x-] \d* student student (\d*) .*mv_ukaz", + results['mv_ls_size']) + mv_ls_size = int(task2_re.group(1)) + task2_ok = mv_ls_size <= 17 and mv_ls_size > 2 + except: + task2_ok = False if task2_ok: score += 1 else: - hints += ["wrong rename size"] + hints += ["wrong mv_command size or owner"] pre_src = set([i.strip() for i in results['pre_mv_src'].split('\n')[3:-1]]) pre_dst = set([i.strip() for i in results['pre_mv_dst'].split('\n')[3:-1]]) task2_ok = task2_ok and pre_src == set(fnames) @@ -309,7 +322,9 @@ def task_check(results, params): hints += ["wrong syslog count"] # task5_ok = True - if int(results['curl_env'].strip()) != int(params['curl_n_images']): + try: + assert int(results['curl_env'].strip()) != int(params['curl_n_images']) + except: task5_ok = False if task5_ok: score += 2 @@ -319,7 +334,9 @@ def task_check(results, params): wc_cat_str = 'cat {}/lines.txt'.format(params['wc_dirname']) if not wc_cat_str == results['wc_lines'][:len(wc_cat_str)]: task6_ok = False - if int(results['wc_lines'][len(wc_cat_str):].strip()) != int(params['wc_n_lines']): + try: + assert int(results['wc_lines'][len(wc_cat_str):].strip()) == int(params['wc_n_lines']) + except: task6_ok = False if task6_ok: score += 1 @@ -330,9 +347,9 @@ def task_check(results, params): def prepare_disks(templates, params): # d = templates['simpleArbiterDhcp'] import random - print "Haha!" - print params - print templates + #print "Haha!" + #print params + #print templates d = templates['malishell'] r = random.Random(params['file_creator_random_seed']) # rename |