From be58248c925298e2254aa25b88bf0682bba8358e Mon Sep 17 00:00:00 2001 From: "mj7196@student.uni-lj.si" Date: Mon, 22 Dec 2014 18:45:53 +0000 Subject: Popravil sem metodo gen_params, in dolocil tri parametre (Ime,Datum,Sifra), ce kaj se ni vredu le sporocite git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@125 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/custom_rdate/task.py | 54 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'kpov_judge/tasks') diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py index 561c7d1..515792d 100644 --- a/kpov_judge/tasks/custom_rdate/task.py +++ b/kpov_judge/tasks/custom_rdate/task.py @@ -76,12 +76,11 @@ computers = { networks = { 'net1': {'public': False}, 'test-net': {'public': True} } -# TODO: (polz) pick the parameters you need! ASAP! +# Tu sem dolocil parametre params_meta = { - 'IP_NM': {'descriptions': {'si': 'Naslov maliNetworkManager'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True}, - 'DNS_NM': {'descriptions': {'si': 'DNS za maliNetworkManager'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True}, - 'IP_static': {'descriptions': {'si': 'Naslov maliBrezNetworkManager'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True}, - 'DNS_static': {'descriptions': {'si': 'DNS za maliBrezNetworkManager'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True}, + 'Ime':{} + 'Datum':{} + 'Sifra':{} } def task(IP_NM, DNS_NM, IP_static, DNS_static): @@ -105,28 +104,37 @@ def task(IP_NM, DNS_NM, IP_static, DNS_static): sA.logout() sB.logout() return results + + +#Dolocil sem tri parametre in sicer jih lahko vidite v prams_meta, +#zato prosim da jih upostevate v naslednih nalogah. -import datetime -import random def gen_params(user_id, params_meta): - # TODO: (polz) tole nima smisla. Za začetek datetime in random - # ne bosta importana v test_task.py, kjer se bo tale koda izvajala. - # Prosim, s kolegi se pogovorite in si izmislite, katere parametre bi - # lahko uporabili. - crke = "ABCDEFGHIJKLMNOPRSTUVZXYQW" - time = datetime.datetime.now().strftime("%Y%m%d%H%M%S") - sifra = "" - for x in time: - for i in x: - sifra+=random.choice(crke) + i + random.choice(crke) + import socket + import struct + import datetime + params = dict() r = random.Random(user_id) - 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) - params[user_id] = sifra + params['Ime'] = "guliver" + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect(("ntp1.arnes.si",37)) + + podatek = s.recv(4) + stevilka = struct.unpack("!I",podatek) + stevilka = stevilka[0] + t = datetime.date(year=1850,month=1,day=1) + t = t + datetime.timedelta(seconds=stevilka) + params['Datum'] = t + + rez = "" + crke = "ABCDEFGHIJKLMNOPRSTUVZXYQ" + c = random.Random(crke) + for x in user_id: + rez += x + c.choice() + + params['Sifra'] = rez return params def task_check(results, params): -- cgit v1.2.1