From e33085889f26c76587fdab2ad600ed336dc028b5 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 6 Oct 2018 23:35:00 +0200 Subject: Improve ssh error reporting in some tasks --- .../tasks/copy_rename_20_files_tail_env/task.py | 129 +++++++++------------ 1 file changed, 53 insertions(+), 76 deletions(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') 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 7e3c3c8..d817083 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 @@ -116,9 +116,37 @@ params_meta = { } def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string, curl_fname, wc_dirname): - from pexpect import pxssh + import collections import os - # TODO: (polz) this has to be changed! Get a move on! + from pexpect import pxssh + + commands = [ + ('preimenuj', '/bin/ls -a1 {}'.format(file_rename_dirname)), + ('pre_mv_src', '/bin/ls -a1 {}'.format(mv_src_dir)), + ('pre_mv_dst', '/bin/ls -a1 {}'.format(mv_dst_dir)), + ('mv_ls_size', '/bin/ls -l ~/mv_ukaz'), + (None, '. ~/mv_ukaz'), + ('post_mv_src', '/bin/ls -a1 {}'.format(mv_src_dir)), + ('post_mv_dst', '/bin/ls -a1 {}'.format(mv_dst_dir)), + + # mama_ukaz + (None, 'cd /home/student/grep_test_dir'), + (None, '. ~/mama_ukaz'), + ('grep_napake', 'cat ~/napake.txt'), + ('grep_mama', 'cat ~/mama.txt'), + + # sledenje syslog + (None, 'date'), + ('syslog_start_time', '/usr/local/bin/syslog_spammer &'), + ('syslog_result', '/home/student/syslog_ukaz.sh'), + ('syslog_end_time', 'date'), + + ('cowsay', 'cowsay "{}"'.format(cowsay_string)), + ('wc_origfile', 'cat {}/count.txt'.format(wc_dirname)), + ('wc_lines', 'cat {}/lines.txt'.format(wc_dirname)), + ] + + # TOD: (polz) this has to be changed! Get a move on! # # sv: Z primozem lavricem sva skusala nekaj narediti # Ker gen params ni narejen, sklepam da je "Mapa" na namizju, @@ -126,80 +154,31 @@ def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_strin # v mojimenik se nahaja mojimenikfile # mama2 vsebuje "mama" #Stirje subt-aski dodani.By Mihec. - results = dict() - conn = pxssh.pxssh() - conn.login(IP_malishell, 'student', 'vaje') - # preimenuj datoteke - conn.sendline('/bin/ls -a1 {}'.format(file_rename_dirname)) - conn.prompt() - results['preimenuj'] = conn.before - # premakni datoteke s cim krajsim ukazom - conn.sendline('/bin/ls -a1 {}'.format(mv_src_dir)) - conn.prompt() - results['pre_mv_src'] = conn.before - conn.sendline('/bin/ls -a1 {}'.format(mv_dst_dir)) - conn.prompt() - results['pre_mv_dst'] = conn.before - conn.sendline('/bin/ls -l ~/mv_ukaz') - conn.prompt() - results['mv_ls_size'] = conn.before - conn.sendline('. ~/mv_ukaz') - conn.prompt() - conn.sendline('/bin/ls -a1 {}'.format(mv_src_dir)) - conn.prompt() - results['post_mv_src'] = conn.before - conn.sendline('/bin/ls -a1 {}'.format(mv_dst_dir)) - conn.prompt() - results['post_mv_dst'] = conn.before - # mama_ukaz - # - conn.sendline('cd /home/student/grep_test_dir') - conn.prompt() - conn.sendline('. ~/mama_ukaz') - conn.prompt() - conn.sendline('cat ~/napake.txt') - conn.prompt() - results['grep_napake'] = conn.before - conn.sendline('cat ~/mama.txt') - conn.prompt() - results['grep_mama'] = conn.before - # sledenje syslog - conn.sendline('date') - conn.prompt() - conn.sendline('/usr/local/bin/syslog_spammer &') - conn.prompt() - results['syslog_start_time'] = conn.before - conn.sendline('/home/student/syslog_ukaz.sh') - conn.prompt() - results['syslog_result'] = conn.before - conn.sendline('date') - conn.prompt() - results['syslog_end_time'] = conn.before - conn.sendline('cowsay "{}"'.format(cowsay_string)) - conn.prompt() - results['cowsay'] = conn.before + results = collections.defaultdict(str) + try: + s = pxssh.pxssh(encoding='utf-8') + s.login(IP_malishell, 'student', 'vaje') + results['ssh'] = True + for test, command in commands: + s.sendline(command) + s.prompt() + if test: + results[test] = s.before + s.logout() + except Exception as ex: + results['ssh'] = str(ex) + 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 - conn.sendline('cat {}/lines.txt'.format(wc_dirname)) - conn.prompt() - results['wc_lines'] = conn.before - conn.logout() - #results['curl'] = subprocess.check_output(["cat","/home/student/Desktop/website.txt"]) + #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"]) - #results['cowsay'] = subprocess.check_output(["dpkg --get-selections | grep","cowsay"]) - #results['phttp'] = subprocess.check_output(["lsof -i ",":8080"]) return results def gen_params(user_id, params_meta): @@ -218,7 +197,6 @@ def gen_params(user_id, params_meta): params['curl_n_images'] = str(r.randint(30,100)) params['wc_dirname'] = homedir + "".join([r.choice("rstuvxz") for i in range(8)]) params['wc_n_lines'] = str(r.randint(200, 600)) - #params['phttp'] = "8080" #params['images'] = subprocess.check_output(["echo","$images"]) return params @@ -232,22 +210,20 @@ def task_check(results, params): for i in range(20): fnames.append("".join([ r.choice("_abcdefghijk") for j in range(8)])) #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 - # print( results['preimenuj']) + + # preimenuj 1 lines = results['preimenuj'].split("\n") task1_ok = len(lines) == len(fnames) + 4 task1_ok = task1_ok and lines[0].find(params['file_rename_dirname']) >= 0 task1_ok = task1_ok and lines[1].strip() == "." task1_ok = task1_ok and lines[2].strip() == ".." - # print task1_ok for fname in fnames: - # print task1_ok, fname, results['preimenuj'].find(fname) task1_ok = task1_ok and results['preimenuj'].find(fname) > 0 if task1_ok: score += 2 else: hints += ["wrong dash rename"] + # premakni datoteke s cim krajsim ukazom fnames = [] try: @@ -264,6 +240,8 @@ def task_check(results, params): score += 1 else: hints += ["wrong mv_command size or owner"] + + # rename files 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) @@ -276,8 +254,8 @@ def task_check(results, params): score += 1 else: hints += ["wrong rename files"] + # mama_ukaz - # task3_ok = True mama_fnames = [] for i in range(20): @@ -291,8 +269,6 @@ def task_check(results, params): linknames = [] for i in range(20): linknames.append("".join([ r.choice("123456789abcdefghijk") for j in range(8)])) - #print( results['grep_mama']) - #print( results['grep_napake']) for i in dirnames + linknames + papa_fnames: if (i not in papa_fnames) and results['grep_napake'].find(i) < 0: task3_ok = False @@ -310,6 +286,7 @@ def task_check(results, params): score += 2 else: hints += ["mama cries"] + # sledenje syslog #print( results['syslog_start_time']) #print( results['syslog_result']) @@ -321,7 +298,7 @@ def task_check(results, params): score += 1 else: hints += ["wrong syslog count"] - # + task5_ok = True try: assert int(results['curl_env'].strip()) == int(params['curl_n_images']) -- cgit v1.2.1 From 9c51bbe5016495c714789f5df01806a6d366e11a Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 6 Oct 2018 23:56:03 +0200 Subject: Rename kpov_random_helpers to kpov_util --- kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') 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 d817083..d7f0cc6 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 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # TODO (polz): instructions = { @@ -188,12 +188,12 @@ def gen_params(user_id, params_meta): homedir = '/home/student/' r = random.Random(user_id) params['file_creator_random_seed'] = str(r.random()) - params['file_rename_dirname'] = homedir + kpov_random_helpers.default_generators['dirname'](r) + params['file_rename_dirname'] = homedir + kpov_util.default_generators['dirname'](r) params['mv_src_dir'] = homedir + "".join([r.choice("abcdefgh") for i in range(6)]) params['mv_dst_dir'] = homedir + "".join([r.choice("ijklmnop") for i in range(6)]) params['syslog_n_zmeda'] = str(r.randint(5, 15)) - params['cowsay_string'] = kpov_random_helpers.default_generators['short_text'](r) - params['curl_fname'] = kpov_random_helpers.default_generators['filename'](r) + params['cowsay_string'] = kpov_util.default_generators['short_text'](r) + params['curl_fname'] = kpov_util.default_generators['filename'](r) params['curl_n_images'] = str(r.randint(30,100)) params['wc_dirname'] = homedir + "".join([r.choice("rstuvxz") for i in range(8)]) params['wc_n_lines'] = str(r.randint(200, 600)) @@ -386,4 +386,4 @@ def prepare_disks(templates, task_params, global_params): 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['simpleArbiterDhcpGW'], global_params) + #write_default_config(templates['simpleArbiterDhcpGW'], global_params) -- cgit v1.2.1 From b5b35faea7f4205f353f57178ddc795b7dce5043 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 7 Oct 2018 19:02:26 +0200 Subject: Refactor SSH testing code out of individual tasks Catch SSH errors and report failures as hints. Also some cleanups and 2to3 fixes. --- .../tasks/copy_rename_20_files_tail_env/task.py | 40 ++++++---------------- 1 file changed, 11 insertions(+), 29 deletions(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') 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 d7f0cc6..b7970e7 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 @@ -118,9 +118,16 @@ params_meta = { def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string, curl_fname, wc_dirname): import collections import os - from pexpect import pxssh - commands = [ + # TOD: (polz) this has to be changed! Get a move on! + # + # sv: Z primozem lavricem sva skusala nekaj narediti + # Ker gen params ni narejen, sklepam da je "Mapa" na namizju, + # imena datotek pa so: 1,1-,2,2-,3,3-,4,5,6,7,8,9,.mama1,mama2,mama3,mama4,mama5,mojimenik,novi,oce1 + # v mojimenik se nahaja mojimenikfile + # mama2 vsebuje "mama" + #Stirje subt-aski dodani.By Mihec. + results = kpov_util.ssh_test(IP_malishell, 'student', 'vaje', ( ('preimenuj', '/bin/ls -a1 {}'.format(file_rename_dirname)), ('pre_mv_src', '/bin/ls -a1 {}'.format(mv_src_dir)), ('pre_mv_dst', '/bin/ls -a1 {}'.format(mv_dst_dir)), @@ -144,29 +151,7 @@ def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_strin ('cowsay', 'cowsay "{}"'.format(cowsay_string)), ('wc_origfile', 'cat {}/count.txt'.format(wc_dirname)), ('wc_lines', 'cat {}/lines.txt'.format(wc_dirname)), - ] - - # TOD: (polz) this has to be changed! Get a move on! - # - # sv: Z primozem lavricem sva skusala nekaj narediti - # Ker gen params ni narejen, sklepam da je "Mapa" na namizju, - # imena datotek pa so: 1,1-,2,2-,3,3-,4,5,6,7,8,9,.mama1,mama2,mama3,mama4,mama5,mojimenik,novi,oce1 - # v mojimenik se nahaja mojimenikfile - # mama2 vsebuje "mama" - #Stirje subt-aski dodani.By Mihec. - results = collections.defaultdict(str) - try: - s = pxssh.pxssh(encoding='utf-8') - s.login(IP_malishell, 'student', 'vaje') - results['ssh'] = True - for test, command in commands: - s.sendline(command) - s.prompt() - if test: - results[test] = s.before - s.logout() - except Exception as ex: - results['ssh'] = str(ex) + )) try: results['curl_env'] = os.environ['images'] @@ -309,11 +294,8 @@ def task_check(results, params): else: hints += ["wrong image count"] task6_ok = True - 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 try: - assert int(results['wc_lines'][len(wc_cat_str):].strip()) == int(params['wc_n_lines']) + assert int(results['wc_lines'].strip()) == int(params['wc_n_lines']) except: task6_ok = False if task6_ok: -- cgit v1.2.1 From 3091fc2877600f7926ed6a596c316183499125f8 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 7 Oct 2018 19:11:49 +0200 Subject: Remove coding: lines Python 3 source is utf-8 by default. --- kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 1 - 1 file changed, 1 deletion(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') 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 b7970e7..6e0df54 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 @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- # kpov_util should be imported by add_assignment.py # TODO (polz): -- cgit v1.2.1 From 149952ce32fc8a35729be7891fca1a447771cb44 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 7 Oct 2018 19:14:05 +0200 Subject: Run dos2unix on deviant files --- .../solution/solution.py | 184 ++++++++++----------- 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/solution/solution.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/solution/solution.py index 7a26b77..6036cd1 100644 --- a/kpov_judge/tasks/copy_rename_20_files_tail_env/solution/solution.py +++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/solution/solution.py @@ -1,92 +1,92 @@ -# preimenuj vse datoteke tako, da zamenjaš minuse s podčrtaji -def rename(): - import os - for filename in os.listdir('.'): - os.rename(filename, filename.replace('-', '_')) - -# Napiši čim krajši ukaz, ki vse datoteke iz /home/user/mapa/mojimenik premakne v /home/user/novi -def mv_novi(): - import os - for filename in os.listdir("/home/user/mapa/mojimenik/"): - os.rename('/home/user/mapa/mojimenik/' + filename, '/home/user/novi/' + filename) - -# 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) -def mama(): - import os - import re - import mmap - mama = '' - wrong = '' - 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: - wrong = wrong + filename + "\n" - open('mama.txt', 'w').write(mama) - open('napake.txt', 'w').write(wrong) - -# 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. -def checker(): - 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 += 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 + število okoljskih spremenljivk, ki v imenu ali vrednosti ne vsebujejo besede TEST. Primer: polz37 -def env(): - 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'] + repr(c) - -# S pomočjo programa cURL shrani vsebino spletne strani www.google.com v datoteko z imenom website.txt -def googl(): - import urllib.request, urllib.error, urllib.parse - open('website.txt', 'w').write(urllib.request.urlopen('http://www.google.com').read()) - -# Napiši ukaz, ki bo število pojavitev značke
v datoteki website.txt dodal na konec te iste datoteke brez, da bi se ukaz zapisal v zgodovino ukazov "bash history" -def div(): - import re - import mmap - f = open('website.txt', 'r+') - data = mmap.mmap(f.fileno(), 0) - me = re.findall('<[^/<>]*div[^>]*>', data) - open('website.txt', 'a+').write(repr(len(me))) - -# Napiši ukaz brez uporabe programa cron, kateri 5 minut po izvedbi izpiše vsebino imenika v katerem se trenutno nahajaš -def sleep(): - import time - import os - time.sleep(300) - print(os.listdir('.')) - -# 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 -def server(): - import http.server - import socketserver - httpd = socketserver.TCPServer(("", 8000), http.server.SimpleHTTPRequestHandler) - httpd.serve_forever() +# preimenuj vse datoteke tako, da zamenjaš minuse s podčrtaji +def rename(): + import os + for filename in os.listdir('.'): + os.rename(filename, filename.replace('-', '_')) + +# Napiši čim krajši ukaz, ki vse datoteke iz /home/user/mapa/mojimenik premakne v /home/user/novi +def mv_novi(): + import os + for filename in os.listdir("/home/user/mapa/mojimenik/"): + os.rename('/home/user/mapa/mojimenik/' + filename, '/home/user/novi/' + filename) + +# 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) +def mama(): + import os + import re + import mmap + mama = '' + wrong = '' + 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: + wrong = wrong + filename + "\n" + open('mama.txt', 'w').write(mama) + open('napake.txt', 'w').write(wrong) + +# 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. +def checker(): + 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 += 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 + število okoljskih spremenljivk, ki v imenu ali vrednosti ne vsebujejo besede TEST. Primer: polz37 +def env(): + 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'] + repr(c) + +# S pomočjo programa cURL shrani vsebino spletne strani www.google.com v datoteko z imenom website.txt +def googl(): + import urllib.request, urllib.error, urllib.parse + open('website.txt', 'w').write(urllib.request.urlopen('http://www.google.com').read()) + +# Napiši ukaz, ki bo število pojavitev značke
v datoteki website.txt dodal na konec te iste datoteke brez, da bi se ukaz zapisal v zgodovino ukazov "bash history" +def div(): + import re + import mmap + f = open('website.txt', 'r+') + data = mmap.mmap(f.fileno(), 0) + me = re.findall('<[^/<>]*div[^>]*>', data) + open('website.txt', 'a+').write(repr(len(me))) + +# Napiši ukaz brez uporabe programa cron, kateri 5 minut po izvedbi izpiše vsebino imenika v katerem se trenutno nahajaš +def sleep(): + import time + import os + time.sleep(300) + print(os.listdir('.')) + +# 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 +def server(): + import http.server + import socketserver + httpd = socketserver.TCPServer(("", 8000), http.server.SimpleHTTPRequestHandler) + httpd.serve_forever() -- cgit v1.2.1 From dbf585c2a59dbcb7f6d803d5756826b562cd7f43 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 7 Oct 2018 19:38:40 +0200 Subject: Fix or remove hashbangs --- kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 1 - 1 file changed, 1 deletion(-) (limited to 'kpov_judge/tasks/copy_rename_20_files_tail_env') 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 6e0df54..aa57d3e 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 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # kpov_util should be imported by add_assignment.py # TODO (polz): -- cgit v1.2.1