summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormp1846@student.uni-lj.si <mp1846@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-27 23:45:29 +0000
committermp1846@student.uni-lj.si <mp1846@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-27 23:45:29 +0000
commit20876239fdedc54bcc7048bd2e55051b79d08c0a (patch)
tree3e5965516a1fceb6d18d2c69ed0db111f0ec5cd5
parent1f892308faad1ef57c789f26410c415c35977f5d (diff)
Malenkost spremenjena ena naloga ("prestej stevilo pojavitev dolocenega stringa v html kodi...") + dokoncan moj del check_task funkcije.
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@243 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
-rw-r--r--kpov_judge/tasks/copy_rename_20_files_tail_env/task.py10
1 files changed, 7 insertions, 3 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 098b1c4..7669d66 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
@@ -12,7 +12,7 @@ V domači mapi najdeš imenik Mapa z 20 datotekami.
- Napiši ukaz, ki s pomočjo ukaza grep v datoteko "mama.txt" izpiše vse navade (ne skrite) datoteke 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)
- Napiši ukaz, ki bo 5s sledil vsebini /var/log/syslog. V primeru, da se v syslogu pojavi niz "zmeda", naj program izpiše "imam ga". Poleg tega naj program med sledenjem syslog-u odšteva od 5 do 1 (vsako sekundo naj se izpiše naslednja številka.
- Nastavi okoljsko spremenljivko TEST, da bo imela isto vrednost kot okoljska spremenljivka USER + število okoljskih spremenljivk, ki v imenu ali vrednosti ne vsebujejo besede TEST. Primer: polz37
- - S pomočjo programa cURL shrani vsebino spletne strani www.google.com v datoteko z imenom website.txt
+ - S pomočjo programa cURL preštej pojavitev niza "images" v html kodi (shranjena stran 24ur.com) in število zapiši v spremenljivko $images.
- V imeniku "Mapa" najdeš datoteko count.txt. Preštej število vrstic v njej in rezultat zapiši v novo datoteko lines.txt
- Namesti paket "cowsay" in ga preizkusi :)
- Napiši najkrajši ukaz, ki s pomočjo Pythona zažene preprost (integriran) HTTP strežnik kateri streže datoteke iz imenika iz katerega je bil pognan na vratih 8000
@@ -33,7 +33,7 @@ second(5 to 1) to show the status of the tracker.
- Set the variable TEST, which will have the same value as the
variable USER + the number of variables that do not include the name
TEST, for example polz37.
-- With the help of cURL fetch the website content of www.google.com and save it into file named website.txt
+- With the help of cURL count the number of "images" string occurences in html code (saved 24ur.com website) and save it to variable $images.
- In directory "Mapa" exists file count.txt
- Install packet "cowsay" and test it :)
- Write shortest command possible which will with the help of Python start a simple (integrated) HTTP server and will serve the files from the current directory on port 8000."""
@@ -104,6 +104,8 @@ def task():
results['curl'] = subprocess.check_output(["cat","/home/student/Desktop/website.txt"])
+ results['chkimages'] = subprocess.check_output(["curl www.24ur.com >> dlg.txt && cat dlg.txt | grep -c ","images"])
+
results['count'] = subprocess.check_output(["wc","/home/student/Desktop/count.txt"])
results['lines'] = subprocess.check_output(["cat","/home/student/Desktop/lines.txt"])
@@ -119,11 +121,13 @@ def task():
def gen_params(user_id, params_meta):
import random
+ import subprocess
params = dict()
r = random.Random(user_id)
params['cwsay'] = "cowsay"
params['phttp'] = "8080"
+ params['images'] = subprocess.check_output(["echo","$images"])
return params
def task_check(results, params):
@@ -148,7 +152,7 @@ def task_check(results, params):
if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1:
score += 1
#TASK 6
- if results['NoNameATM'].find('NoFormatATM'.format(params['NoNameAtm'])) > -1:
+ if int(results['chkimages']) == int(params['images']):
score += 1
#TASK 7
if int(results['count'].split()[0]) == int(results['lines'].split()[0]):