diff python/pythonServer.py @ 2997:a10cbbccc4f3

#193. Partial files save with prefix ‘update’. Partials are deleted once full test is submitted and saved.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 02 Aug 2017 08:50:19 +0100
parents a087cb7b5972
children 03b0e5dc57e6
line wrap: on
line diff
--- a/python/pythonServer.py	Wed Aug 02 08:29:23 2017 +0100
+++ b/python/pythonServer.py	Wed Aug 02 08:50:19 2017 +0100
@@ -138,12 +138,15 @@
     global curSaveIndex
     options = self.path.rsplit('?')
     options = options[1].rsplit('&')
+    update = False
     for option in options:
         optionPair = option.rsplit('=')
         if optionPair[0] == "key":
             key = optionPair[1]
         elif optionPair[0] == "saveFilenamePrefix":
             prefix = optionPair[1]
+        elif optionPair[0] == "state":
+            update = optionPair[1] == "update"
     if key == None:
         self.send_response(404)
         return
@@ -153,6 +156,8 @@
     postVars = self.rfile.read(varLen)
     print("Saving file key "+key)
     filename = prefix+'-'+key+'.xml'
+    if update:
+        filename = "update-"+filename
     file = open('../saves/'+filename,'wb')
     file.write(postVars)
     file.close()
@@ -173,6 +178,8 @@
         self.wfile.write(bytes(reply, "utf-8"))
     curSaveIndex += 1
     curFileName = 'test-'+str(curSaveIndex)+'.xml'
+    if update == False:
+        os.remove("../saves/update-"+filename)
 
 def poolXML(s):
     pool = ET.parse('../tests/pool.xml')