summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-09-26 16:23:29 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-09-26 16:23:29 +0200
commit03c9d6d8441e3293b058fed270866419781b734c (patch)
treea456f12f5c26c836685c6e47c95cfe2897e43723 /kpov_judge/tasks
parent3938c69f3e1586c1ffbcae5395414ca8480e6ba4 (diff)
Run 2to3
Some stuff is broken now.
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r--kpov_judge/tasks/basic_network_gcc/task.py24
-rw-r--r--kpov_judge/tasks/copy_rename_100_files/task.py4
-rw-r--r--kpov_judge/tasks/copy_rename_20_files_tail_env/task.py60
-rw-r--r--kpov_judge/tasks/custom_rdate/rDate.py2
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py16
-rw-r--r--kpov_judge/tasks/dhcp_dns_predefined_ip/task.py4
-rw-r--r--kpov_judge/tasks/edit_find_grep_compile_convert/task.py18
-rw-r--r--kpov_judge/tasks/entrance_exam/task.py2
-rw-r--r--kpov_judge/tasks/isc_dhcp_live_boot/task.py4
-rw-r--r--kpov_judge/tasks/ldap_import/task.py2
-rw-r--r--kpov_judge/tasks/ldap_search/task.py16
-rw-r--r--kpov_judge/tasks/mock_entrance_exam/task.py24
-rw-r--r--kpov_judge/tasks/nat_port_forward/task.py10
-rw-r--r--kpov_judge/tasks/nat_vlc/task.py4
-rw-r--r--kpov_judge/tasks/nat_vlc/video.py2
-rw-r--r--kpov_judge/tasks/network_boot_custom_program/task.py2
-rw-r--r--kpov_judge/tasks/openvpn_multiple_hops/task.py2
-rw-r--r--kpov_judge/tasks/openvpn_simple_smb/task.py16
-rw-r--r--kpov_judge/tasks/openwrt/task.py2
-rw-r--r--kpov_judge/tasks/public_ip_ssh/task.py10
-rw-r--r--kpov_judge/tasks/public_ssh_motd_http/task.py2
-rw-r--r--kpov_judge/tasks/radius_multiple_realms/task.py2
-rw-r--r--kpov_judge/tasks/radius_mysql_pam/task.py34
-rw-r--r--kpov_judge/tasks/rdate_64bit/task.py2
-rw-r--r--kpov_judge/tasks/rename_grep_network/task.py8
-rw-r--r--kpov_judge/tasks/set_ip_dhcp_hostname/task.py2
-rw-r--r--kpov_judge/tasks/set_ip_static_dhcp/task.py4
-rw-r--r--kpov_judge/tasks/set_motd/task.py8
-rw-r--r--kpov_judge/tasks/smb_nfs/task.py4
-rw-r--r--kpov_judge/tasks/snmp_agent_uptime/task.py22
-rw-r--r--kpov_judge/tasks/snmp_alarms_interfaces/task.py2
-rw-r--r--kpov_judge/tasks/vlc_stream_rtp/task.py4
32 files changed, 159 insertions, 159 deletions
diff --git a/kpov_judge/tasks/basic_network_gcc/task.py b/kpov_judge/tasks/basic_network_gcc/task.py
index eeb7d1c..ae690f0 100644
--- a/kpov_judge/tasks/basic_network_gcc/task.py
+++ b/kpov_judge/tasks/basic_network_gcc/task.py
@@ -8,7 +8,7 @@
# - switch to a real SSH/SFTP client to properly handle filenames
instructions = {
- 'si': u'''
+ 'si': '''
Postavite dva navidezna računalnika - SimpleArbiter in Student.
Oba naj bosta povezana na internet. Poleg tega mora biti
Student na naslovu {student_IP} dostopen s SimpleArbiter.
@@ -31,7 +31,7 @@ Napišite skripto ali program {P_script} v domačem imeniku uporabnika student,
Lastnik vseh ustvarjenih datotek mora biti uporabnik student.
Gesla uporabnika student (vaje) ne smete spreminjati.''',
- 'en': u'''
+ 'en': '''
''',
}
@@ -124,10 +124,10 @@ def task(student_IP, net_prog_name,
conn.login(student_IP, 'student', 'vaje')
results = dict()
r = random.Random(int(param_gen_seed))
- env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(11)])
+ env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(11)])
- arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(13)])
- stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(17)])
+ arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(13)])
+ stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(17)])
conn.sendline('ls -l {}'.format(P_script))
conn.prompt()
results['script_ls'] = conn.before
@@ -157,8 +157,8 @@ def gen_params(user_id, params_meta):
r = random.Random(user_id+'evil cornholio')
params = kpov_random_helpers.default_gen(user_id, params_meta)
homedir = '/home/student/'
- params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in xrange(5)])
- params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in xrange(5)]) + ".c"
+ params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)])
+ params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in range(5)]) + ".c"
params['param_gen_seed'] = str(r.randint(0, 2**24))
params['c_destroy_gen_seed'] = str(r.randint(0, 2**24))
dest_net = kpov_random_helpers.IPv4_subnet_gen(r, '10.0.2.128/26', 26)
@@ -175,7 +175,7 @@ def task_check(results, params):
r = 0
arg_len = len(arg)
env_len = len(var)
- for i in xrange(100):
+ for i in range(100):
s_out += chr(32 + ((ord(arg[i % arg_len]) ^ ord(var[i % env_len])) % 64))
r += ord(arg[i % arg_len]) + ord(var[i % env_len]) + i;
if (i % 17 == 0):
@@ -192,9 +192,9 @@ def task_check(results, params):
score = 0
hints = []
r = random.Random(int(params['param_gen_seed']))
- env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(11)])
- arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(13)])
- stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(17)])
+ env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(11)])
+ arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(13)])
+ stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(17)])
expected_script_stdout, expected_script_stderr, rval = test_out_gen(
params['arg_c'], env_val
)
@@ -292,7 +292,7 @@ done; }&
sh_path = r.choice(['/usr/share/doc', '/var/lib', '/usr/local/share', '/etc/alternatives'])
sh_file = sh_path + '/' + params['net_prog_name']
d.write(sh_file, evil_shell_source)
- d.chmod(0775, sh_file)
+ d.chmod(0o775, sh_file)
d.write("/etc/rc.local", """#!/bin/sh -e
export PATH=$PATH:{}
{} &
diff --git a/kpov_judge/tasks/copy_rename_100_files/task.py b/kpov_judge/tasks/copy_rename_100_files/task.py
index 2c3700f..9ad4d66 100644
--- a/kpov_judge/tasks/copy_rename_100_files/task.py
+++ b/kpov_judge/tasks/copy_rename_100_files/task.py
@@ -8,14 +8,14 @@
# - switch to a real SSH/SFTP client to properly handle filenames
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika. Za prvega uporabi sliko diska simpleArbiterDhcp. Na drugem računalniku
ustvari uporabnika test z geslom test.
Na sliki diska simpleArbiterDhcp najdeš imenik s 100 datotekami. Prekopiraj vse datoteke na drugi računalnik v domači imenik uporabnika test.
Spremeni vsebino datotek tako, da vse male črke spremeniš v velike. Poskrbi, da se bo s prvega računalnika (simpleArbiterDhcp) mogoče prek
ssh prijaviti na drugi računalnik in prebrati predelane datoteke.
""",
- 'en': u'''
+ 'en': '''
Create two virtual machines. For the first, use the `simpleArbiterDhcp' image.
On the second machine, create a user `test' with the password `test'.
The `simpleArbiterDhcp' disk image contains a folder with 100 files. Copy all
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 e82e8ca..7e3c3c8 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
@@ -4,7 +4,7 @@
# TODO (polz):
instructions = {
- 'si':u"""
+ 'si':"""
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
@@ -32,7 +32,7 @@ V domači mapi najdeš imenik {file_rename_dirname} z 20 datotekami.
v novo vrstico v count.txt in rezultat zapiši v novo datoteko - lines.txt
v istem imeniku.
""",
- 'en':u"""
+ 'en':"""
Log into the system as student using vaje as your password.
In your home folder you will find a directory called {file_rename_dirname}
containing 20 files.
@@ -210,13 +210,13 @@ def gen_params(user_id, params_meta):
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['mv_src_dir'] = homedir + "".join([r.choice("abcdefgh") for i in xrange(6)])
- params['mv_dst_dir'] = homedir + "".join([r.choice("ijklmnop") for i in xrange(6)])
+ 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['curl_n_images'] = str(r.randint(30,100))
- params['wc_dirname'] = homedir + "".join([r.choice("rstuvxz") for i in xrange(8)])
+ 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"])
@@ -229,8 +229,8 @@ def task_check(results, params):
hints = []
r = random.Random(params['file_creator_random_seed'])
fnames = []
- for i in xrange(20):
- fnames.append("".join([ r.choice("_abcdefghijk") for j in xrange(8)]))
+ 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
@@ -251,8 +251,8 @@ def task_check(results, params):
# premakni datoteke s cim krajsim ukazom
fnames = []
try:
- for i in xrange(40):
- fnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ for i in range(40):
+ fnames.append("".join([ r.choice("123456789abcdefghijk") for j in range(8)]))
task2_re = re.search(
r"-rw[x-][r-][w-][x-][r-][w-][x-] \d* student student (\d*) .*mv_ukaz",
results['mv_ls_size'])
@@ -280,17 +280,17 @@ def task_check(results, params):
#
task3_ok = True
mama_fnames = []
- for i in xrange(20):
- mama_fnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ for i in range(20):
+ mama_fnames.append("".join([ r.choice("123456789abcdefghijk") for j in range(8)]))
papa_fnames = []
- for i in xrange(20):
- papa_fnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ for i in range(20):
+ papa_fnames.append("".join([ r.choice("123456789abcdefghijk") for j in range(8)]))
dirnames = []
- for i in xrange(20):
- dirnames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ for i in range(20):
+ dirnames.append("".join([ r.choice("123456789abcdefghijk") for j in range(8)]))
linknames = []
- for i in xrange(20):
- linknames.append("".join([ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ 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:
@@ -356,17 +356,17 @@ def prepare_disks(templates, task_params, global_params):
# rename
d.mkdir(task_params['file_rename_dirname'])
d.chown(1000, 1000, task_params['file_rename_dirname'])
- for i in xrange(20):
+ for i in range(20):
fname = task_params['file_rename_dirname'] + '/' + "".join(
- [r.choice("-abcdefghijk") for j in xrange(8)])
+ [r.choice("-abcdefghijk") for j in range(8)])
d.touch(fname)
d.chown(1000, 1000, fname)
# mv ukaz
d.mkdir(task_params['mv_src_dir'])
d.chown(1000, 1000, task_params['mv_src_dir'])
- for i in xrange(40):
+ for i in range(40):
fname = task_params['mv_src_dir'] + '/' +"".join(
- [r.choice("123456789abcdefghijk") for j in xrange(8)])
+ [r.choice("123456789abcdefghijk") for j in range(8)])
d.touch(fname)
d.chown(1000, 1000, fname)
d.mkdir(task_params['mv_dst_dir'])
@@ -374,27 +374,27 @@ def prepare_disks(templates, task_params, global_params):
# grep mama
# mama fnames
d.mkdir('/home/student/grep_test_dir')
- for i in xrange(20):
+ for i in range(20):
d.write("/home/student/grep_test_dir/" + "".join(
- [ r.choice("123456789abcdefghijk") for j in xrange(8)]),
+ [ r.choice("123456789abcdefghijk") for j in range(8)]),
"mama")
# papa fnames
- for i in xrange(20):
+ for i in range(20):
d.write("/home/student/grep_test_dir/" + "".join(
- [ r.choice("123456789abcdefghijk") for j in xrange(8)]),
+ [ r.choice("123456789abcdefghijk") for j in range(8)]),
"papa")
# dirnames
- for i in xrange(20):
+ for i in range(20):
d.mkdir("/home/student/grep_test_dir/" + "".join(
- [ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ [ r.choice("123456789abcdefghijk") for j in range(8)]))
# linknames
- for i in xrange(20):
+ for i in range(20):
d.ln_sf("mali zeleni", "/home/student/grep_test_dir/" + "".join(
- [ r.choice("123456789abcdefghijk") for j in xrange(8)]))
+ [ r.choice("123456789abcdefghijk") for j in range(8)]))
# sledenje syslog
spammer_source = "#!/bin/sh\n" + int(task_params['syslog_n_zmeda']) * "logger zmeda\n"
d.write("/usr/local/bin/syslog_spammer", spammer_source)
- d.chmod(0775, "/usr/local/bin/syslog_spammer")
+ d.chmod(0o775, "/usr/local/bin/syslog_spammer")
# curl
l1 = ['images'] * int(task_params['curl_n_images'])
l2 = ['imeges'] * r.randint(30, 100)
diff --git a/kpov_judge/tasks/custom_rdate/rDate.py b/kpov_judge/tasks/custom_rdate/rDate.py
index 1ceafaa..97885b0 100644
--- a/kpov_judge/tasks/custom_rdate/rDate.py
+++ b/kpov_judge/tasks/custom_rdate/rDate.py
@@ -14,5 +14,5 @@ podatek = s.recv(4)
stevilka = struct.unpack("!I", podatek)
st= stevilka[0]-220898800
date = time.localtime(st)
-print(time.strftime('%Y-%m-%d %H:%M:%S'),date)
+print((time.strftime('%Y-%m-%d %H:%M:%S'), date))
s.send(date)
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
index 867e037..b84a2b7 100644
--- a/kpov_judge/tasks/custom_rdate/task.py
+++ b/kpov_judge/tasks/custom_rdate/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
# TODO: finish this!
instructions = {
- 'si':u"""
+ 'si':"""
Postavite dva navidezna racunalnika:
- SimpleArbiterDhcpRdate s slike diska simpleArbiterRdate ter
- rdateClient.
@@ -18,7 +18,7 @@ predznaceno celo število, pri čemer naj uporablja zapis z debelim koncem
(big endian).
Število naj program izpiše na standardni izhod v obliki niza.
""",
- 'en':u"""
+ 'en':"""
Setup two virtual machines:
- SimpleArbiterDhcpRdate from disk image simpleArbiterRdate and
- rdateClient.
@@ -69,9 +69,9 @@ networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
# Tu sem dolocil parametre
params_meta = {
- 'RDATE_OFFSET':{'descriptions': {'si': u'Napaka v času pri rdate', 'en': 'Timekeeping error for rdate'}, 'w': False, 'public': False, 'type': 'integer', 'generated': True},
- 'PROGRAM_FILENAME':{'descriptions': {'si': u'Ime programa', 'en': 'program filename'}, 'w': False, 'public': True, 'type': 'integer', 'generated': True},
- 'IP_RDATECLIENT':{'descriptions': {'si': u'IP rdateClient', "en": "rdateClient's IP"}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
+ 'RDATE_OFFSET':{'descriptions': {'si': 'Napaka v času pri rdate', 'en': 'Timekeeping error for rdate'}, 'w': False, 'public': False, 'type': 'integer', 'generated': True},
+ 'PROGRAM_FILENAME':{'descriptions': {'si': 'Ime programa', 'en': 'program filename'}, 'w': False, 'public': True, 'type': 'integer', 'generated': True},
+ 'IP_RDATECLIENT':{'descriptions': {'si': 'IP rdateClient', "en": "rdateClient's IP"}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
}
def task(IP_RDATECLIENT, PROGRAM_FILENAME):
@@ -90,7 +90,7 @@ def task(IP_RDATECLIENT, PROGRAM_FILENAME):
client.connect(IP_RDATECLIENT, username=peer_user, password=peer_passwd)
#client.login(IP_RDATECLIENT, peer_user, peer_passwd)
r = random.Random(PROGRAM_FILENAME)
- for i in xrange(10):
+ for i in range(10):
stdin, stdout, stderr = client.exec_command(
'~/{}'.format(PROGRAM_FILENAME))
data = struct.pack("!I", r.randint(0, 2**32))
@@ -128,7 +128,7 @@ def task_check(results, params):
r = random.Random(params['PROGRAM_FILENAME'])
score = 0.0
hints = []
- for i in xrange(10):
+ for i in range(10):
data = base64.decodestring(results['in_' + str(i)])
x = struct.pack("!I", r.randint(0, 2**32))
if data != x:
@@ -174,5 +174,5 @@ t = time.time() + 2208988800 + offset
sys.stdout.write(struct.pack("!I", int(t)))
"""
d.write('/usr/local/bin/kpovrdate', s2)
- d.chmod(0775, '/usr/local/bin/kpovrdate')
+ d.chmod(0o775, '/usr/local/bin/kpovrdate')
write_default_config(templates['simpleArbiterDhcpGWRdate'], global_params)
diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
index e46e6b8..40507d5 100644
--- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
+++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari tri navidezne računalnike. Za enega (SimpleArbiter) uporabi sliko diska simpleArbiter. Na drugega (DHCP_server) postavi strežnika DHCP in DNS in poskrbi, da ta računalnik dobi IP naslov {IP_server}. Poskrbi, da bo preostali računalnik (DHCP_client) dobil naslov {IP_client}, ki mu ga določi DHCP strežnik. Poskrbi še,da DNS strežnik vrne za hostname {HOSTNAME_X} IP naslov {IP_X}.
"""
}
@@ -102,7 +102,7 @@ def gen_params(user_id, params_meta):
r = random.Random(user_id+"bla")
net = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24)
params['IP_server'], params['IP_client'], params['IP_X'] = kpov_random_helpers.IPv4_addr_gen(r, net, 3)
- params['HOSTNAME_X'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in xrange(5)])
+ params['HOSTNAME_X'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)])
return params
diff --git a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
index 7a358b9..3d9aafa 100644
--- a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
+++ b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
@@ -9,7 +9,7 @@
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika s slikama diskov
- SimpleArbiter s sliko diska simpleArbiterDhcp in
SmallStudent s sliko diska student-entrance2.
@@ -33,7 +33,7 @@ Program naj prebere znak s standardnega vhoda.
Če je B-ti bit nastavljen na 0, naj program izpiše "ti".
Program poimenuj {progname} in ga spravi v domači imenik {testuser}.
""",
- 'en': u'''
+ 'en': '''
Create two virtual machines
- SimpleArbiter using simpleArbiterDhcp as the disk image and
SmallStudent using student-entrance2 as its disk.
@@ -275,31 +275,31 @@ def task_check(results, params):
break
hints += ["wrong file contents\n" + str(diff_pos[1])]
#hints += ["wrong file contents"]
- expected_ls = u"ls -l ~/{dstfile}\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}.*\r\n".format(**params)
+ expected_ls = "ls -l ~/{dstfile}\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}.*\r\n".format(**params)
if re.match(expected_ls, results["dst_ls"]):
score += 3
else:
- hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"]]
+ hints += ["missing file or wrong user/permissions\n" + results["dst_ls"]]
if results["home_ls"].find(params['progname']) > -1:
score += 2
else:
hints += ["missing program"]
- expected_tita = u""
+ expected_tita = ""
r = random.Random(params['pubseed'])
for i in range(N_TITA):
b = r.randint(0, 7)
x_i = r.randint(37, 127)
x = oct(x_i).replace('o', '')
- expected_tita += u'echo -e "\\{}" | ~/{} {}\r\n'.format(x, params['progname'], b)
+ expected_tita += 'echo -e "\\{}" | ~/{} {}\r\n'.format(x, params['progname'], b)
if x_i & (1 << b):
- expected_tita += u"ta\r\n"
+ expected_tita += "ta\r\n"
else:
- expected_tita += u"ti\r\n"
+ expected_tita += "ti\r\n"
if results["tita_return"] == expected_tita:
score += 2
else:
#hints += [u"program output incorrect\n" + results["tita_return"] + expected_tita]
- hints += [u"program output incorrect\n" + results["tita_return"]]
+ hints += ["program output incorrect\n" + results["tita_return"]]
return score, hints
diff --git a/kpov_judge/tasks/entrance_exam/task.py b/kpov_judge/tasks/entrance_exam/task.py
index 6984c7c..bfefbd1 100644
--- a/kpov_judge/tasks/entrance_exam/task.py
+++ b/kpov_judge/tasks/entrance_exam/task.py
@@ -1,2 +1,2 @@
-instructions = {'si': u"""
+instructions = {'si': """
Reši pristopni kolokvij z visoko oceno.""" }
diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py
index 15d150e..c5ac728 100644
--- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py
+++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py
@@ -5,7 +5,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi štiri navidezne računalnike - simpleArbiter, DHCP_server,
BootableClientA ter BootableClientB.
@@ -107,7 +107,7 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME):
import pexpect
import re
import tftpy
- import StringIO
+ import io
import time
results={}
# TODO (polz): Please use pexpect instead of os.system, it's much nicer.
diff --git a/kpov_judge/tasks/ldap_import/task.py b/kpov_judge/tasks/ldap_import/task.py
index 654e810..0df173e 100644
--- a/kpov_judge/tasks/ldap_import/task.py
+++ b/kpov_judge/tasks/ldap_import/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika - SimpleArbiter z diskom simpleArbiterDhcp ter LDAPServer.
Na LDAPServer namesti strežnik LDAP. Na SimpleArbiter preberi ime domene DOMENA,
uporabniško ime BIND_DN ter geslo BIND_PASS. Poskrbi, da se bo lahko klient s simpleArbiterDhcp povezal na LDAP strežnik na LDAPServer.
diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py
index 0e906ae..886bf07 100644
--- a/kpov_judge/tasks/ldap_search/task.py
+++ b/kpov_judge/tasks/ldap_search/task.py
@@ -7,7 +7,7 @@
#
# TODO: finish this!
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika - SimpleArbiter z diskom simpleArbiterDhcp
ter LDAPServer.
@@ -32,7 +32,7 @@ O = Organization
OU = Organizational Unit
DC = Domain Component
""",
- 'en': u"""
+ 'en': """
Create two virtual machines - SimpleArbiter using the disk simpleArbiterDhcp
and LDAPServer.
@@ -96,12 +96,12 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'LDAP_IP': {'descriptions': {'si': u'IP strežnika', 'en': 'Server IP'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
- 'DOMAIN': {'descriptions': {'si': u'Domena (poddomena kpov.lusy.fri.uni-lj.si)', 'en': 'Domain (subdomain of kpov.lusy.fri.uni-lj.si)'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
- 'LDAP_USERNAME': {'descriptions': {'si': u'Uporabniško ime v LDAP', 'en': 'Username in LDAP'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
- 'LDAP_PASSWORD': {'descriptions': {'si': u'Geslo v LDAP', 'en': 'LDAP password'}, 'w': False, 'public':True, 'type': 'password', 'generated': True},
- 'BIND_USERNAME': {'descriptions': {'si': u'Uporabniško ime za dostop do LDAP (bind)', 'en': 'Bind username in LDAP'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
- 'BIND_PASSWORD': {'descriptions': {'si': u'Geslo za dostop do LDAP (bind)', 'en': 'Bind password in LDAP'}, 'w': False, 'public':True, 'type': 'password', 'generated': True},
+ 'LDAP_IP': {'descriptions': {'si': 'IP strežnika', 'en': 'Server IP'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'DOMAIN': {'descriptions': {'si': 'Domena (poddomena kpov.lusy.fri.uni-lj.si)', 'en': 'Domain (subdomain of kpov.lusy.fri.uni-lj.si)'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
+ 'LDAP_USERNAME': {'descriptions': {'si': 'Uporabniško ime v LDAP', 'en': 'Username in LDAP'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
+ 'LDAP_PASSWORD': {'descriptions': {'si': 'Geslo v LDAP', 'en': 'LDAP password'}, 'w': False, 'public':True, 'type': 'password', 'generated': True},
+ 'BIND_USERNAME': {'descriptions': {'si': 'Uporabniško ime za dostop do LDAP (bind)', 'en': 'Bind username in LDAP'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
+ 'BIND_PASSWORD': {'descriptions': {'si': 'Geslo za dostop do LDAP (bind)', 'en': 'Bind password in LDAP'}, 'w': False, 'public':True, 'type': 'password', 'generated': True},
}
def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASSWORD):
diff --git a/kpov_judge/tasks/mock_entrance_exam/task.py b/kpov_judge/tasks/mock_entrance_exam/task.py
index 52772a3..a6e3c8c 100644
--- a/kpov_judge/tasks/mock_entrance_exam/task.py
+++ b/kpov_judge/tasks/mock_entrance_exam/task.py
@@ -8,7 +8,7 @@
# - switch to a real SSH/SFTP client to properly handle filenames
instructions = {
- 'si': u'''
+ 'si': '''
Postavite dva navidezna računalnika - SimpleArbiter in Student.
Oba naj bosta povezana na internet. Poleg tega mora biti
Student na naslovu {student_IP} dostopen s SimpleArbiter.
@@ -28,7 +28,7 @@ Napišite skripto ali program {P_script} v domačem imeniku uporabnika student,
Lastnik vseh ustvarjenih datotek mora biti uporabnik student.
Gesla uporabnika student (vaje) ne smete spreminjati.''',
- 'en': u'''Set up two virtual machines - SimpleArbiter and Student.
+ 'en': '''Set up two virtual machines - SimpleArbiter and Student.
Both should be connected to the Internet. Student should also be accessible
from SimpleArbiter at the address {student_IP}.
@@ -142,10 +142,10 @@ def task(student_IP, net_prog_name,
conn.login(student_IP, 'student', 'vaje')
results = dict()
r = random.Random(int(param_gen_seed))
- env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(11)])
+ env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(11)])
- arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(13)])
- stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(17)])
+ arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(13)])
+ stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(17)])
conn.sendline('ls -l {}'.format(P_script))
conn.prompt()
results['script_ls'] = conn.before
@@ -175,8 +175,8 @@ def gen_params(user_id, params_meta):
r = random.Random(user_id+'evil cornholio')
params = kpov_random_helpers.default_gen(user_id, params_meta)
homedir = '/home/student/'
- params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in xrange(5)])
- params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in xrange(5)]) + ".c"
+ params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)])
+ params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in range(5)]) + ".c"
params['param_gen_seed'] = str(r.randint(0, 2**24))
params['c_destroy_gen_seed'] = str(r.randint(0, 2**24))
dest_net = kpov_random_helpers.IPv4_subnet_gen(r, '10.0.2.128/26', 26)
@@ -193,7 +193,7 @@ def task_check(results, params):
r = 0
arg_len = len(arg)
env_len = len(var)
- for i in xrange(100):
+ for i in range(100):
s_out += chr(32 + ((ord(arg[i % arg_len]) ^ ord(var[i % env_len])) % 64))
r += ord(arg[i % arg_len]) + ord(var[i % env_len]) + i;
if (i % 17 == 0):
@@ -210,9 +210,9 @@ def task_check(results, params):
score = 0
hints = []
r = random.Random(int(params['param_gen_seed']))
- env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(11)])
- arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(13)])
- stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in xrange(17)])
+ env_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(11)])
+ arg_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(13)])
+ stdin_val = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ012345') for i in range(17)])
expected_script_stdout, expected_script_stderr, rval = test_out_gen(
params['arg_c'], env_val
)
@@ -315,7 +315,7 @@ done;
sh_path = r.choice(['/usr/share/doc', '/var/lib', '/usr/local/share', '/etc/alternatives'])
sh_file = sh_path + '/' + task_params['net_prog_name']
d.write(sh_file, evil_shell_source)
- d.chmod(0775, sh_file)
+ d.chmod(0o775, sh_file)
d.write("/etc/rc.local", """#!/bin/sh -e
export PATH=$PATH:{}
nohup {} &
diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py
index 645b20f..2688268 100644
--- a/kpov_judge/tasks/nat_port_forward/task.py
+++ b/kpov_judge/tasks/nat_port_forward/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi tri računalnike - SimpleArbiter z diska simpleArbiter, TestClient z diska testClient in NATServer. NATServer naj ima dva omrežna vmesnika - z enim naj bo
povezan na omrežje, od koder bo imel dostop do Interneta, z drugim pa na SimpleArbiter. TestClient naj bo povezan na isto omrežje z dostopom do Interneta kot NATServer.
Poskrbi, da bo NATServer služil kot DHCP strežnik ter privzeti prehod za SimpleArbiter.
@@ -66,7 +66,7 @@ params_meta = {
'IP_NAT': {'descriptions': {'si': 'Naslov NATServer, dostopen s TestClient'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
'PORT_OUTER': {'descriptions': {'si': 'Zunanja vrata'}, 'w': False, 'public':True, 'type': 'port', 'generated': True},
'PORT_INNER': {'descriptions': {'si': 'Notranja vrata'}, 'w': False, 'public': True, 'type': 'port', 'generated': True},
- 'NET': {'descriptions': {'si': u'Področje naslovov med SimpleArbiter in TestClient'}, 'w': False, 'public': True, 'type': 'NET', 'generated': True},
+ 'NET': {'descriptions': {'si': 'Področje naslovov med SimpleArbiter in TestClient'}, 'w': False, 'public': True, 'type': 'NET', 'generated': True},
}
def task(IP_TEST_CLIENT, IP_NAT, PORT_OUTER, PORT_INNER, NET):
@@ -86,7 +86,7 @@ def task(IP_TEST_CLIENT, IP_NAT, PORT_OUTER, PORT_INNER, NET):
k = r.randint(10, 15)
results['pre_nc'] = str(k)
results['nc_pre'] = ""
- for i in xrange(k):
+ for i in range(k):
sshconn.sendline("nc {} {}".format(IP_NAT, PORT_OUTER))
sshconn.sendline()
sshconn.sendintr()
@@ -96,7 +96,7 @@ def task(IP_TEST_CLIENT, IP_NAT, PORT_OUTER, PORT_INNER, NET):
sshconn.sendline()
sshconn.prompt()
sshconn.sendline("nc {} {}".format(IP_NAT, PORT_OUTER))
- results['post_nc'] = "".join([r.choice("abcd\n") for i in xrange(100)])
+ results['post_nc'] = "".join([r.choice("abcd\n") for i in range(100)])
sshconn.sendline(results['post_nc'])
time.sleep(1)
sshconn.sendintr()
@@ -126,7 +126,7 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
- import cPickle
+ import pickle
#if results is None:
# with open('bla.pickle') as f:
# results = cPickle.load(f)
diff --git a/kpov_judge/tasks/nat_vlc/task.py b/kpov_judge/tasks/nat_vlc/task.py
index 59cceaa..cf3947b 100644
--- a/kpov_judge/tasks/nat_vlc/task.py
+++ b/kpov_judge/tasks/nat_vlc/task.py
@@ -9,7 +9,7 @@
#TODO: finish this
instructions = {
- 'si':u"""
+ 'si':"""
Postavi dva navidezna računalnika - SimpleArbiter z diskom simpleArbiter
ter NATServer. NATServer naj ima dva omrežna vmesnika - z enim naj bo povezan
na lokalno omrežje, na katerem naj bo tudi simpleArbiter, z drugim pa na
@@ -20,7 +20,7 @@ ustvarite še uporabnika {IP_NAT_user}.
Poskrbi, da bo SimpleArbiter prek DHCP dobil naslov {IP_simple}.
Poskrbi, da bo NATServer deloval kot prehod za SimpleArbiter in izvajal NAT.
""",
- 'en':u"""
+ 'en':"""
Set up two virtual machines - SimpleArbiter (using the disc simpleArbiter) and
NATServer. NATServer should have two network adapters. Connect the first
adapter to SimpleArbiter and the second adapter to the Internet. Configure the
diff --git a/kpov_judge/tasks/nat_vlc/video.py b/kpov_judge/tasks/nat_vlc/video.py
index 7593d43..3c21c82 100644
--- a/kpov_judge/tasks/nat_vlc/video.py
+++ b/kpov_judge/tasks/nat_vlc/video.py
@@ -31,7 +31,7 @@ bashCommand = "avconv -i video.mp4 -c:a copy video1.avi"
os.system(bashCommand)
# This loop will increas videos length by adding more picesec of the original video.
-last = input("Set video length in seconds: ")
+last = int(input("Set video length in seconds: "))
bashCommand = "avconv -i concat:video.avi\|video1.avi -c copy video.avi"
for i in range(0, last-2):
os.system(bashCommand)
diff --git a/kpov_judge/tasks/network_boot_custom_program/task.py b/kpov_judge/tasks/network_boot_custom_program/task.py
index 891bc4a..db011c9 100644
--- a/kpov_judge/tasks/network_boot_custom_program/task.py
+++ b/kpov_judge/tasks/network_boot_custom_program/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi tri navidezne računalnike - simpleArbiter, DHCP_server, DHCP_client.
Na računalniku DHCP_server najdeš program A. DHCP_server nastavi tako, da se bo
DHCP_client lahko zagnal prek mreže. Na datotečni sistem, s katerega
diff --git a/kpov_judge/tasks/openvpn_multiple_hops/task.py b/kpov_judge/tasks/openvpn_multiple_hops/task.py
index 32b1835..5e54a1f 100644
--- a/kpov_judge/tasks/openvpn_multiple_hops/task.py
+++ b/kpov_judge/tasks/openvpn_multiple_hops/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi 4 navidezne računalnike - SimpleArbiter z diska simpleArbiterDhcp, A, B ter C.
Na računalnikih A, B in C ustvari uporabnika test z geslom test.
Poskrbi, da bodo vsi štirje na istem navideznem fizičnem omrežju. Naslov omrežja (NET_PHYS) ter naslove
diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py
index 1ff035b..2db4337 100644
--- a/kpov_judge/tasks/openvpn_simple_smb/task.py
+++ b/kpov_judge/tasks/openvpn_simple_smb/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi dva navidezna računalnika - SimpleArbiter z diska SimpleArbiterVPN ter
VPNClient1. Poskrbite, da bosta povezana med seboj in v Internet.
Na VPNClient1 namestite OpenVPN in program za nadzor nad virtualnimi napravami
@@ -20,7 +20,7 @@ Nato poskrbite, da bo na VPNClient1 na navideznem omrežju prek NFS omogočen
dostop do imenika /home/test/{DIRNAME}.
V ta imenik skopirajte datoteke, ki so prek SMB dostopne na SimpleArbiter.
""",
- 'en':u"""
+ 'en':"""
Setup two virtual machines - SimpleArbiterVPN and a VPN client (VPNClient1).
Set the client's network up so that it has access to the internal network and
the internet.
@@ -244,12 +244,12 @@ def task_check(results, params):
# get r into the correct state
r = random.Random(params['secret_random_seed'])
s = "\n".join([
- "".join([r.choice("0123456789abcdef") for i in xrange(32)])
- for i in xrange(16)])
+ "".join([r.choice("0123456789abcdef") for i in range(32)])
+ for i in range(16)])
keyfile = kpov_random_helpers.fname_gen(r, extension=False)
# now check the filenames
fnames_ok = True
- for i in xrange(3):
+ for i in range(3):
fname = kpov_random_helpers.fname_gen(r, False)
foo = kpov_random_helpers.fortune(r, 4096)
pos = results['SimpleArbiter_ls'].find(fname + '.txt')
@@ -299,8 +299,8 @@ def prepare_disks(templates, task_params, global_params):
import random
r = random.Random(task_params['secret_random_seed'])
s = "\n".join([
- "".join([r.choice("0123456789abcdef") for i in xrange(32)])
- for i in xrange(16)])
+ "".join([r.choice("0123456789abcdef") for i in range(32)])
+ for i in range(16)])
s = """#
# 2048 bit OpenVPN static key
#
@@ -318,7 +318,7 @@ iface tap0 inet static
netmask 255.255.255.0
""".format(task_params['IP_SimpleArbiterVPN'])
templates['simpleArbiterDhcpGWVPN'].write_append("/etc/network/interfaces", netaddr_s)
- for i in xrange(3):
+ for i in range(3):
fname = kpov_random_helpers.fname_gen(r, False)
templates['simpleArbiterDhcpGWVPN'].write(
"/srv/smb/" + fname + '.txt',
diff --git a/kpov_judge/tasks/openwrt/task.py b/kpov_judge/tasks/openwrt/task.py
index 0439700..057fb96 100644
--- a/kpov_judge/tasks/openwrt/task.py
+++ b/kpov_judge/tasks/openwrt/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi dva navidezna računalnika - simpleArbiter z diska SimpleArbiter ter
OpenWRT z diska OpenWRT. Na disku OpenWRT je nameščena distribucija OpenWRT.
Nastavi OpenWRT tako, da bo imel dva omrežna vmesnika - en naj bo povezan na Internet,
diff --git a/kpov_judge/tasks/public_ip_ssh/task.py b/kpov_judge/tasks/public_ip_ssh/task.py
index b8f1d87..a566aa5 100644
--- a/kpov_judge/tasks/public_ip_ssh/task.py
+++ b/kpov_judge/tasks/public_ip_ssh/task.py
@@ -6,7 +6,7 @@
OrderedDict = SON
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika. Za disk enega (imenujmo ga SimpleArbiter) uporabite
sliko diska Test. Na drugega (imenujmo ga A) namesti poljubno Linux distribucijo. Na SimpleArbiter
preberi uporabniško ime in geslo uporabnika, ki ga moraš ustvariti na A. Poskrbi, da se bo novoustvarjeni
@@ -30,9 +30,9 @@ computers = {
networks = { 'net1': {'public': True}, 'net2': {'public': True} }
params_meta = {
- 'peer_ip': {'descriptions': {'si': u'Naslov ssh strežnika'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
- 'peer_user': {'descriptions': {'si': u'ime uporabnika'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
- 'peer_passwd': {'descriptions': {'si': u'geslo uporabnika'}, 'w': False, 'public': True, 'type': 'password', 'generated': True},
+ 'peer_ip': {'descriptions': {'si': 'Naslov ssh strežnika'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'peer_user': {'descriptions': {'si': 'ime uporabnika'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
+ 'peer_passwd': {'descriptions': {'si': 'geslo uporabnika'}, 'w': False, 'public': True, 'type': 'password', 'generated': True},
}
def task(peer_ip, peer_user, peer_passwd):
@@ -50,7 +50,7 @@ def task_check(results, params):
try:
s.login(peer_ip, peer_user, peer_passwd)
s.logout()
- except Exception, e:
+ except Exception as e:
return 0, [str(e)]
return 10, []
diff --git a/kpov_judge/tasks/public_ssh_motd_http/task.py b/kpov_judge/tasks/public_ssh_motd_http/task.py
index 6ea4239..df6ba32 100644
--- a/kpov_judge/tasks/public_ssh_motd_http/task.py
+++ b/kpov_judge/tasks/public_ssh_motd_http/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Na internet postavi računalnik, ki bo dostopen prek ssh in http.
Poskrbi, da bo na računalniku ustvarjen uporabnik test z geslom test. Ob prijavi naj se
uporabniku v MOTD izpiše (le) zgodbica ali pesmica, ki vam je všeč, dolžine vsaj 50 znakov.
diff --git a/kpov_judge/tasks/radius_multiple_realms/task.py b/kpov_judge/tasks/radius_multiple_realms/task.py
index 407af21..c879d56 100644
--- a/kpov_judge/tasks/radius_multiple_realms/task.py
+++ b/kpov_judge/tasks/radius_multiple_realms/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi tri navidezne računalnike - SimpleArbiter z diska simpleArbiterDhcp,
RadiusA ter RadiusB. Na simpleArbiterDhcp preberi imeni domen DOMENA_A ter DOMENA_B,
uporabniški imeni USER_A in USER_B, gesli PASSWORD_A in PASSWORD_B ter skrivnosti
diff --git a/kpov_judge/tasks/radius_mysql_pam/task.py b/kpov_judge/tasks/radius_mysql_pam/task.py
index 8957c6b..a3f86f7 100644
--- a/kpov_judge/tasks/radius_mysql_pam/task.py
+++ b/kpov_judge/tasks/radius_mysql_pam/task.py
@@ -3,7 +3,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari dva navidezna računalnika - SimpleArbiter z diska simpleArbiterDhcp ter
RadiusServer. Na RadiusServer namesti FreeRadius ter MySQL.
@@ -26,7 +26,7 @@ Nastavi PAM za prijavo (login) tako, da bo dovolj, če se uporabnik na ssh
predstavi z uporabniškim imenom in geslom, ki sta veljavna na FreeRadius,
ne glede na /etc/shadow oziroma /etc/password.
""",
- 'en':u"""
+ 'en':"""
Create two virtual machines - SimpleArbiter using the disk simpleArbiterDhcp
and RadiusServer. On RadiusServer, install FreeRadius and MySQL.
@@ -89,10 +89,10 @@ networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
'IP_RS': {'descriptions': {'si': 'Naslov RadiusServer', 'en': 'RadiusServer IP address'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
'RADIUS_SECRET':{'descriptions': {'si': 'Skrivnost RADIUS', 'en': 'RADIUS secret'}, 'w': False, 'public':True, 'type': 'password', 'generated': True},
- 'RADIUS_USERNAME': {'descriptions': {'si': u'Uporabniško ime', 'en': 'Username'}, 'w': True, 'public':True, 'type': 'username', 'generated': False},
- 'RADIUS_PASSWORD': {'descriptions': {'si': u'Geslo uporabnika', 'en': 'Password'}, 'w': False, 'public':True, 'type': None, 'generated': True},
- 'MYSQL_DB_NAME': {'descriptions': {'si': u'Ime baze v mysql', 'en': 'Database name'}, 'w': False, 'public':True, 'type': None, 'generated': True},
- 'MYSQL_ADMIN_USER':{'descriptions': {'si': u'Uporabniško ime za dostop do MySQL', 'en': 'MySQL username'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
+ 'RADIUS_USERNAME': {'descriptions': {'si': 'Uporabniško ime', 'en': 'Username'}, 'w': True, 'public':True, 'type': 'username', 'generated': False},
+ 'RADIUS_PASSWORD': {'descriptions': {'si': 'Geslo uporabnika', 'en': 'Password'}, 'w': False, 'public':True, 'type': None, 'generated': True},
+ 'MYSQL_DB_NAME': {'descriptions': {'si': 'Ime baze v mysql', 'en': 'Database name'}, 'w': False, 'public':True, 'type': None, 'generated': True},
+ 'MYSQL_ADMIN_USER':{'descriptions': {'si': 'Uporabniško ime za dostop do MySQL', 'en': 'MySQL username'}, 'w': False, 'public':True, 'type': 'username', 'generated': True},
'MYSQL_ADMIN_PASSWORD': {'descriptions': {'si': 'Geslo za dostop do MySQL', 'en': 'MySQL password'}, 'w': True, 'public':True, 'type': 'password', 'generated': True},
'MYSQL_SEED':{'descriptions': {'si': 'seed', 'en': 'seed'}, 'w': False, 'public':True, 'type': None, 'generated': True},
}
@@ -169,8 +169,8 @@ def task_check(results, params):
# print "Test OK"
score += 2
else:
- hints.append(u'radtest connect output incorrect:' + results['Test_RadiusServer'])
- print (results['Test_RadiusServer'], s)
+ hints.append('radtest connect output incorrect:' + results['Test_RadiusServer'])
+ print((results['Test_RadiusServer'], s))
# Testiranje podatkovne base mysql
s = "Welcome to the MySQL monitor.*Type 'help;' or '\\\\h' for help\\. Type '\\\\c' to clear the current input statement\\.\r\n"
if re.search(s, results['mysql_login'], flags=re.DOTALL):
@@ -178,44 +178,44 @@ def task_check(results, params):
score += 1
else:
hints.append("mysql connection string incorrect")
- print (results['mysql_login'], s)
+ print((results['mysql_login'], s))
s = " USE {MYSQL_DB_NAME}\r\nReading table information.*Database changed\r\n".format(**params)
if re.search(s, results['database_connect'], flags=re.DOTALL):
# print "database_connect OK"
score += 1
else:
hints.append('mysql table information string incorrect')
- print (results['database_connect'],)
+ print((results['database_connect'],))
s = " SELECT UserName, Value FROM radcheck;\r\n.*{RADIUS_USERNAME} *| *{RADIUS_PASSWORD}".format(**params)
if re.search(s, results['select_from_users'], flags=re.DOTALL):
# print "select_from_users OK"
score += 2
else:
hints.append('mysql user entry in table check failed')
- print (results['select_from_users'], )
+ print((results['select_from_users'], ))
s = r"Sent Access-Request Id [0-9]+ from ([0-9]|\.)+:[0-9]+ to {0}:1812 length [0-9]+\r\n\tUser-Name = \"{1}\"\r\n\tUser-Password = \"{2}\".*Access-Accept Id [0-9]+ from {0}".format(params['IP_RS'], MYSQL_TEST_USER, MYSQL_TEST_PASSWORD)
if re.search(s, results['radtest_OK'], flags=re.DOTALL):
# print "radtest_OK OK"
score += 2
else:
- hints.append(u'radtest output incorrect:' + results['radtest_OK'])
- print (s, results['radtest_OK'])
+ hints.append('radtest output incorrect:' + results['radtest_OK'])
+ print((s, results['radtest_OK']))
- s = ur"Sent Access-Request Id [0-9]+ from ([0-9]|\.)+:[0-9]+ to {0}:1812 length [0-9]+\r\n\tUser-Name = \"{1}\"\r\n\tUser-Password = \"Flügzeug\".*Access-Reject Id [0-9]+ from {0}".format(params['IP_RS'], MYSQL_TEST_USER)
+ s = r"Sent Access-Request Id [0-9]+ from ([0-9]|\.)+:[0-9]+ to {0}:1812 length [0-9]+\r\n\tUser-Name = \"{1}\"\r\n\tUser-Password = \"Flügzeug\".*Access-Reject Id [0-9]+ from {0}".format(params['IP_RS'], MYSQL_TEST_USER)
if re.search(s, results['radtest_NOK'], flags=re.DOTALL):
# print "radtest_NOK OK"
score += 1
else:
- hints.append(u'radtest negative output incorrect: ' + results['radtest_NOK'])
- print (results['radtest_NOK'], s)
+ hints.append('radtest negative output incorrect: ' + results['radtest_NOK'])
+ print((results['radtest_NOK'], s))
s = "{RADIUS_USERNAME}@.*:~\\$".format(**params)
if re.search(s, results['login_test'], flags=re.DOTALL):
# print "login_test OK"
score += 1
else:
hints.append('login test failed')
- print (results['login_test'],s)
+ print((results['login_test'],s))
return score, hints
def prepare_disks(templates, task_params, global_params):
diff --git a/kpov_judge/tasks/rdate_64bit/task.py b/kpov_judge/tasks/rdate_64bit/task.py
index 27d5e5f..87de002 100644
--- a/kpov_judge/tasks/rdate_64bit/task.py
+++ b/kpov_judge/tasks/rdate_64bit/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavi dva navidezna računalnika - SimpleArbiter z diska simpleArbiterDhcp ter
RdateServer. Na RdateServer postavi strežnik, ki bo poslušal na vratih VRATA_X.
Vsakič, ko se na vrata poveže klient, naj strežnik pošlje število sekund od DATUM_X.
diff --git a/kpov_judge/tasks/rename_grep_network/task.py b/kpov_judge/tasks/rename_grep_network/task.py
index ce3661b..e8ce0b2 100644
--- a/kpov_judge/tasks/rename_grep_network/task.py
+++ b/kpov_judge/tasks/rename_grep_network/task.py
@@ -9,7 +9,7 @@
instructions = {
- 'si': u"""
+ 'si': """
Ustvari dva navidezna računalnika s slikama diskov
- SimpleArbiterExam s sliko diska simpleArbiterDhcp in
SmallStudent s slikama diska student-entrance3
@@ -32,7 +32,7 @@ Pazi, da nobena druga datoteka v domačem imeniku v svojem imenu ne bo vsebovala
Poskrbi, da bo lastnik {testuser}, skupina pa naj ostane nespremenjena.
Brati naj jo ima pravico samo lastnik, pisati lastnik in skupina, poganjati nihče.
""",
- 'en': u'''
+ 'en': '''
''',
}
@@ -252,11 +252,11 @@ def task_check(results, params):
hints += ["wrong file contents\n" + str(diff_pos[1])]
#hints += ["wrong file contents"]
params['dstfile'] = dstfile
- expected_dst_ls = u"ls -l ~/\\*I\\*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params)
+ expected_dst_ls = "ls -l ~/\\*I\\*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params)
if re.match(expected_dst_ls, results["dst_ls"]):
score += 2
else:
- hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"] + "\n" + expected_dst_ls]
+ hints += ["missing file or wrong user/permissions\n" + results["dst_ls"] + "\n" + expected_dst_ls]
if results["home_ls"].find(params['dstfile']) > -1:
score += 2
expected_mnts = [
diff --git a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
index 63ba12a..f68c71b 100644
--- a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
+++ b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py
@@ -5,7 +5,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari tri navidezne računalnike. Za disk prvega uporabi sliko diska simpleArbiterDhcp.
Za enega od ostalih dveh (Z_DHCP) poskrbi, da bo dobil IP prek DHCP, pri čemer
naj kot hostname strežniku pošlje ime, ki ga dobiš na simpleArbiterDhcp.
diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py
index c611356..0553585 100644
--- a/kpov_judge/tasks/set_ip_static_dhcp/task.py
+++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py
@@ -3,7 +3,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Ustvari tri navidezne racunalnike. Za prvega
uporabi sliko diska simpleArbiterDhcpGW, za drugega sliko diska
maliNetworkManager, za tretjega sliko diska maliBrezNetworkManager.
@@ -14,7 +14,7 @@ za omrežni vmesnik, temveč bosta delovala ukaza ifup in ifdown.
Na maliNetworkManager nastavi IP naslov {IP_NM} ter DNS {DNS_NM}.
Na maliBrezNetworkManager nastavi IP naslov {IP_static} ter DNS {DNS_static}.
""",
- 'en':u"""Create three virtual machines. Use simpleArbiterDhcpGW as the
+ 'en':"""Create three virtual machines. Use simpleArbiterDhcpGW as the
disk image for the first, maliNetworkManager as the disk image for the second
and maliBrezNetworkManager for the third. The virtual machine names can match
the disks.
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py
index 0e862a6..eadcca7 100644
--- a/kpov_judge/tasks/set_motd/task.py
+++ b/kpov_judge/tasks/set_motd/task.py
@@ -6,7 +6,7 @@
# OrderedDict = SON
instructions = {
- "si":u"""
+ "si":"""
Ustvari dva navidezna računalnika - imenujmo ju SimpleArbiterDhcpGW in
Student. Za računalnik SimpleArbiterDhcpGW uporabite sliko diska, poimenovano
SimpleArbiterDhcpGW.
@@ -25,7 +25,7 @@ vrstica oblike uporabnisko_ime@ime_racunalnika:~$ .
Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v
teh navodilih.
""",
- 'en':u"""
+ 'en':"""
Create two virtual machines - named SimpleArbiterDhcpGW and Student.
For the 'SimpleArbiterDhcpGW', use disc image named SimpleArbiterDhcpGW.
@@ -68,10 +68,10 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'peer_ip': {'descriptions': {'si': u'IP računalnika', 'en':'IP'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'peer_ip': {'descriptions': {'si': 'IP računalnika', 'en':'IP'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
'peer_user': {'descriptions': {'si': 'ime uporabnika', 'en':'Username'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
'peer_passwd': {'descriptions': {'si': 'geslo uporabnika', 'en': 'Password'}, 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
- 'niz': {'descriptions':{'si': u'niz, ki naj se v motd pokaže', 'en': 'The string which should be displayed in the MOTD'}, 'w': False, 'public': True, 'type': 'short_text', 'generated': True},
+ 'niz': {'descriptions':{'si': 'niz, ki naj se v motd pokaže', 'en': 'The string which should be displayed in the MOTD'}, 'w': False, 'public': True, 'type': 'short_text', 'generated': True},
}
def task(peer_ip, peer_user, peer_passwd, niz):
diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py
index 7143cf0..5ea7695 100644
--- a/kpov_judge/tasks/smb_nfs/task.py
+++ b/kpov_judge/tasks/smb_nfs/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
# TODO: dokoncaj!
instructions = {
- 'si':u"""
+ 'si':"""
Postavi dva navidezna računalnika (simpleArbiterDhcp in FileServer).
Poskrbi, da bo imenik {NFS_MOUNT} na FileServer dostopen prek NFS in
@@ -13,7 +13,7 @@ Ime SMB strežnika nastavite na {FILESERVER_NAME}.
SimpleArbiterDhcp naj ima prek NFS pravico pisati po imeniku.
""",
-'en':u"""
+'en':"""
Set up two virtual computers (simpleArbiterDhcp and FileServer).
Make sure that the directory {NFS_MOUNT} on FileServer is accessible
diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py
index 1ec037b..c636549 100644
--- a/kpov_judge/tasks/snmp_agent_uptime/task.py
+++ b/kpov_judge/tasks/snmp_agent_uptime/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
# TODO: finish this.
instructions = {
- 'si':u"""
+ 'si':"""
Naloga: Postavi tri navidezne racunalnike:
- SimpleArbiter s sliko diska simpleArbiterDhcpGW,
- SNMPServer in
@@ -26,7 +26,7 @@ Postavi jo na SNMP klienta, v domaci imenik uporabnika test z geslom test.
Poskrbi, da bodo podatki na SNMPServer dostopni za skupino (community) studentje.
""",
- 'en':u"""
+ 'en':"""
Set up three virtual computers, SimpleArbiter with the disk image simpleArbiterDhcp,
SNMPServer and SNMPClient. Write a program called upminutes. This program should output
the uptime of the computer in minutes. Set it up on SNMPClient in the home directory
@@ -95,11 +95,11 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'SNMP_VALUE': {'descriptions': {'si': u'Vrednost, dostopna prek SNMP', 'en': 'The value available over SNMP'}, 'w': False, 'public':False, 'type': 'short', 'generated': True},
- 'SNMP_UPTIME_OID': {'descriptions': {'si': u'SNMP_UPTIME_OID (za uptime)', 'en': 'SNMP_UPTIME_OID (for the uptime)'}, 'w': False, 'public':True, 'type': 'str', 'generated': True},
- 'SNMP_CLIENT_OID': {'descriptions': {'si': u'SNMP_CLIENT_OID, ki naj ga klient bere', 'en':'The OID that the client should read'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True},
- 'SERVER_IP': {'descriptions': {'si': u'IP SNMP strežnika', 'en':'IP of the SNMP server'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
- 'CLIENT_IP': {'descriptions': {'si': u'IP SNMP klienta', 'en': 'IP of the SNMP client'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'SNMP_VALUE': {'descriptions': {'si': 'Vrednost, dostopna prek SNMP', 'en': 'The value available over SNMP'}, 'w': False, 'public':False, 'type': 'short', 'generated': True},
+ 'SNMP_UPTIME_OID': {'descriptions': {'si': 'SNMP_UPTIME_OID (za uptime)', 'en': 'SNMP_UPTIME_OID (for the uptime)'}, 'w': False, 'public':True, 'type': 'str', 'generated': True},
+ 'SNMP_CLIENT_OID': {'descriptions': {'si': 'SNMP_CLIENT_OID, ki naj ga klient bere', 'en':'The OID that the client should read'}, 'w': False, 'public':True, 'type': 'OID', 'generated': True},
+ 'SERVER_IP': {'descriptions': {'si': 'IP SNMP strežnika', 'en':'IP of the SNMP server'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'CLIENT_IP': {'descriptions': {'si': 'IP SNMP klienta', 'en': 'IP of the SNMP client'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
}
@@ -131,8 +131,8 @@ def task(SERVER_IP, CLIENT_IP, SNMP_UPTIME_OID, SNMP_CLIENT_OID):
return_results['server_OID'] = "\n".join(result_list)
except Exception as exception_error:
# Check for errors and print out results
- print ('ERROR: Occurred during SNMPget for OID %s from %s: '
- '(%s)') % (SNMP_UPTIME_OID, CLIENT_IP, exception_error)
+ print(('ERROR: Occurred during SNMPget for OID %s from %s: '
+ '(%s)') % (SNMP_UPTIME_OID, CLIENT_IP, exception_error))
sys.exit(2)
client.connect(CLIENT_IP, username='test', password='test')
@@ -194,7 +194,7 @@ def task_check(results, params):
if oid.strip() == server_oid and d >= -2 and d <= 5:
found_uptime = True
break
- except Exception, e:
+ except Exception as e:
pass
if len(lines) <= 50 and found_uptime:
score += 3
@@ -232,5 +232,5 @@ if action != '-s' and oid == foo_oid:
print "{val}"
""".format(oid = task_params['SNMP_CLIENT_OID'], val = task_params['SNMP_VALUE'])
templates['simpleArbiterDhcpGWSNMP'].write('/usr/local/bin/snmpext.py', prog)
- templates['simpleArbiterDhcpGWSNMP'].chmod(0755, '/usr/local/bin/snmpext.py')
+ templates['simpleArbiterDhcpGWSNMP'].chmod(0o755, '/usr/local/bin/snmpext.py')
write_default_config(templates['simpleArbiterDhcpGWSNMP'], global_params)
diff --git a/kpov_judge/tasks/snmp_alarms_interfaces/task.py b/kpov_judge/tasks/snmp_alarms_interfaces/task.py
index e37663a..516cc69 100644
--- a/kpov_judge/tasks/snmp_alarms_interfaces/task.py
+++ b/kpov_judge/tasks/snmp_alarms_interfaces/task.py
@@ -4,7 +4,7 @@
# kpov_random_helpers should be imported by add_assignment.py
instructions = {
- 'si':u"""
+ 'si':"""
Postavite tri računalnike - SimpleArbiterSNMP s sliko diska simpleArbiterSNMP, ServerSNMP s sliko
diska serverSNMP ter SNMPClient.
diff --git a/kpov_judge/tasks/vlc_stream_rtp/task.py b/kpov_judge/tasks/vlc_stream_rtp/task.py
index 39b315f..5c8011b 100644
--- a/kpov_judge/tasks/vlc_stream_rtp/task.py
+++ b/kpov_judge/tasks/vlc_stream_rtp/task.py
@@ -6,7 +6,7 @@
# TODO: finish this
instructions = {
- 'si':u"""
+ 'si':"""
Postavi navidezni računalnik SimpleArbiter z diska simpleArbiter
ter StudentVLC z diska student-VLC. Poskrbi, da bosta na istem omrežju, od
koder bosta imela dostop tudi do Interneta Na StudentVLC posodobi datoteko
@@ -17,7 +17,7 @@ lokalnem omrežju prek RTP z imenom toka {TOK} na naslovu {NASLOV}, vrata {PORT}
Računaj, da bodo film lahko videli tvoji sošolci. Kršenje avtorskih pravic
je pri reševanju te naloge strogo prepovedano.
""",
- 'en':u"""
+ 'en':"""
Set up a virtual computer called SimpleArbiter using the simpleArbiter disk and
a virtual computer called StudentVLC using the student-VLC disk. Make sure they
are on the same network and that they have access to the Internet.