From 570f06358422fec64df9a28174760156d050f550 Mon Sep 17 00:00:00 2001 From: "lb5051@student.uni-lj.si" Date: Mon, 15 Dec 2014 16:17:47 +0000 Subject: =?UTF-8?q?Posodobil=20task().=20Napisano=20pribli=C5=BEno,=20deln?= =?UTF-8?q?o=20stestirano,=20ampak=20naj=20bi=20izpolnjevalo=20vse=20funkc?= =?UTF-8?q?ije=20z=20minimalno=20interakcijo=20z=20sistemom.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: Izpolniti, da pravilno dopolnjuje rezutate. git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@76 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/smb_nfs/task.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'kpov_judge/tasks/smb_nfs') diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py index 8769eae..1e6121b 100644 --- a/kpov_judge/tasks/smb_nfs/task.py +++ b/kpov_judge/tasks/smb_nfs/task.py @@ -77,9 +77,42 @@ params_meta = { } def task(SMB_NAME, NFS_MOUNT, SHARED_FILENAME, SHARED_FILENAME_CONTENT): - # mount the NFS mount - # mount the SMB mount - # read the filename content + import subprocess + + # Naslov, na katerem se nahaja streznik. + address = SMB_NAME + # Tabela vseh mountov. + mounts = subprocess.check_output("mount").split("\n") + # Samo mounti na streznik. + srvmounts = [] + for m in mounts: + if str.find(m, address) >= 0: + srvmounts.append(m) + # Mounti so v formatu: + # ["//SMB_NAME/ on NFS_MOUNT type cifs (rw)", ... ] + # example: ["//192.168.1.92/srv/samba on /mnt/samba type cifs (rw)", ... ] + # Seznam mora imeti vnos za NFS in SMB, morata biti obesena na pravo pot in (rw) + for m in srvmounts: + # Dobimo pot, filesystem in pravice iz mounta: + split = m.split() + pot = split[2] + fstype = split[4] + pravice = split[5] + # Pregledamo datoteke v temu direktoriju: + ls = subprocess.check_output(["ls", pot]).split() + # Preverimo ce je v imeniku datoteka: + if SHARED_FILENAME in ls: + # Če je, primerjamo vsebino: + cat = subprocess.check_output(["cat", pot+"/"+SHARED_FILENAME]) + if cat == SHARED_FILENAME_CONTENT: + # DING DING DING PLUS PIKE ZA PRAVO VSEBINO + pass + if pravice == "(rw)": + # BONUS PIKE ZA READ/WRITE PRAVICE + pass + + # Samo delno stestirano! + results = ''.join(random.choice(string.ascii_uppercase) for i in range(12)) #results = "test" return results -- cgit v1.2.1