diff options
author | lb5051@student.uni-lj.si <lb5051@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2014-12-15 16:17:47 +0000 |
---|---|---|
committer | lb5051@student.uni-lj.si <lb5051@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2014-12-15 16:17:47 +0000 |
commit | 570f06358422fec64df9a28174760156d050f550 (patch) | |
tree | 9994a9993990bcdc8fb123866e1d8770cc094d82 | |
parent | 214844d41eaea65366bf9f03d06522a0a425edc9 (diff) |
Posodobil task(). Napisano približno, delno stestirano, ampak naj bi izpolnjevalo vse funkcije z minimalno interakcijo z sistemom.
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
-rw-r--r-- | kpov_judge/tasks/smb_nfs/task.py | 39 |
1 files changed, 36 insertions, 3 deletions
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/<pot_do_direktorija> 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 |