diff options
author | jr1224@student.uni-lj.si <jr1224@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-26 02:13:40 +0000 |
---|---|---|
committer | jr1224@student.uni-lj.si <jr1224@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-01-26 02:13:40 +0000 |
commit | b42f94299c93fbfbcf0e0a4982417692eaa4dfcc (patch) | |
tree | 8be811ed6c02f01a0f9fcb04ab2fc246fe7106d3 | |
parent | c88b6aa20cc7ad2db1adf0610e46111202aa81ff (diff) |
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@235 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rw-r--r-- | kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 69 |
1 files changed, 67 insertions, 2 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 bc4535c..d1b67a4 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 @@ -173,16 +173,81 @@ def prepare_disks(templates, params): pass #preimenuj vse datoteke tako, da zmenjas minuse s podcrtaji -def rename(): +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 mv_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` |