diff options
author | mp1846@student.uni-lj.si <mp1846@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-27 01:02:02 +0000 |
---|---|---|
committer | mp1846@student.uni-lj.si <mp1846@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-27 01:02:02 +0000 |
commit | 4b5abb8584c89f8cabd1fd197b892aa8467ae096 (patch) | |
tree | f6c171097828513f6df17f43a85fe1b66dd47731 /kpov_judge | |
parent | 956969d56e8e8ce7a16f9f3a8be962216da6ff77 (diff) |
Dopolnjena task_check funkcija + dopolnjena task funkcija (goli parametri odpravljeni).
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@237 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r-- | kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 120 |
1 files changed, 17 insertions, 103 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 7b113a2..098b1c4 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 @@ -106,9 +106,11 @@ def task(): results['count'] = subprocess.check_output(["wc","/home/student/Desktop/count.txt"]) + results['lines'] = subprocess.check_output(["cat","/home/student/Desktop/lines.txt"]) + results['cowsay'] = subprocess.check_output(["dpkg --get-selections | grep","cowsay"]) - results['phttp'] = subprocess.check_output(["ps aux | grep ","SimpleHTTPServer"]) + results['phttp'] = subprocess.check_output(["lsof -i ",":8080"]) @@ -116,21 +118,13 @@ def task(): return results def gen_params(user_id, params_meta): - #PLEASE FINISH gen_params I NEED IT FOR TASK CHECK (Primoz Lavric) import random params = dict() + r = random.Random(user_id) - # IP_NM, DNS_NM, IP_static, DNS_static) - dns_servers = ['193.2.1.66', '193.2.1.72', '8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220'] - net = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) - params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) - params['DNS_static'] = r.choice(dns_servers) - count = 0 - while(count<user_id): - params[count]=random.randInt(10000000,99999999) - count=count+1 - return params + params['cwsay'] = "cowsay" + params['phttp'] = "8080" + return params def task_check(results, params): import re @@ -139,32 +133,32 @@ def task_check(results, params): #TO FINISH SCORING WE REQUIRE DICT KEYS AND FUNCTIONS gen_params AND task TO BE FINISHED #POINTS FOR EACH TASK MAY BE ADJUSTED IN THE FUTURE #TASK 1 - if results['preimenuj'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TASK 2 - if results['novi'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TASK 3 - if results['mojimenik'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TASK 4 - if results['mamatxt'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TAKS 5 - if results['napaketxt'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TASK 6 - if results['curl'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: score += 1 #TASK 7 - if results['count'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if int(results['count'].split()[0]) == int(results['lines'].split()[0]): score += 1 #TASK 8 - if results['cowsay'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: + if results['cowsay'].find(params['cwsay']) > -1: score += 1 #TASK 9 - if results['phttp'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1: - score += 2 + if results['phttp'].find(params['phttp']) > -1: + score += 1 return score @@ -172,83 +166,3 @@ def prepare_disks(templates, params): # d = templates['simpleArbiterDhcp'] pass -#preimenuj vse datoteke tako, da zmenjas minuse s podcrtaji -def preimenuj(): - import os - - for filename in os.listdir('.'): - os.rename(filename, filename.replace('-','_')) - -#napisi cimkrajsi ukaz, ki vse datoteke iz /home/user/mapa/mojimenik premakne v /hostuser/novi -def premakni(): - import os - - for filename in os.filename("/home/user/mapa/mojimenik/"): - os.rename('/home/user/mapa/mojimenik/' + filename, '/home/user/novi/' + filename) - - -#napisi ukaz, ki s pomocjo ukaza grep v datoteko "mama.txt" izpise vse navadne (ne skrite) datoteke v trenutnem imeniku, ki vsebujejo niz "mama", v datoteko "napake.txt" pa izpise vse morebitne napake -def izpisi(): - import os - import re - import mmap - - mama ='' - napaka='' - - for filename in os.listdir('.'): - try: - f=open(filename, 'r+') - data=mmap.mmap(f.fileno(), 0) - - if re.search('mama', data): - mama=mama+filename+ "\n" - except ValueError: - napaka=napaka+filename+ "\n" - - open('mama.txt', 'w').write(mama) - - open('napake.txt','w').write(napaka) - -#napisi ukaz, ki bo 5s sledil vsebini /var/log/syslog. V primeru, da se pojavi niz "zmeda", naj program izpise "imam ga". Polega tega naj program med sledenjem odsteva od 5 do 1 -def sledi(): - import time - import re - import mmap - - t=time.time()*1000 - n=t - - f=open('/var/log/syslog', 'r+') - data=mmap.mmap(f.fileno(), 0) - me=re.findall('zmeda', data) - - c=len(me) - - for i in range(5, 0, -1): - print i - n=n+1000 - - while n>t: - f=open('/var/log/syslog', 'r+') - data=mmap.mmap(f.fileno(), 0) - me=re.findall('zmeda', data) - - if len(me)>c: - c=len(me) - print 'imam ga' - - t=time.time()*1000 - -#nastavi okoljsko spremenljivko TEST, da bo imela isto vrednost kot okoljska spremenljivka USER + stevilo okoljskih spremenljivk, ki v imenu ali vrednosti ne vsebujejo besede TEST. Primer: polz37 -def nastaviSpr(): - import os - import re - - c=0 - - for i in os.environ: - if not(re.search('TEST',i) or re.search('TEST', os.environ[i])): - c=c+1 - - os.environ['TEST']=os.environ['USER']+`c` |