Mercurial > hg > webaudioevaluationtool
comparison python/pythonServer.py @ 2940:8805556c0f42
Potential fix for #235
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Thu, 14 Sep 2017 13:10:51 +0100 |
parents | 260efd43fe52 |
children | 24681d53ee7a b09e9b7ef246 |
comparison
equal
deleted
inserted
replaced
2939:5d7e33fd00d8 | 2940:8805556c0f42 |
---|---|
118 key = '' | 118 key = '' |
119 while key == '': | 119 while key == '': |
120 tempKey = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(32)); | 120 tempKey = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(32)); |
121 if (os.path.isfile("saves/save-"+tempKey+".xml") == False): | 121 if (os.path.isfile("saves/save-"+tempKey+".xml") == False): |
122 key = tempKey | 122 key = tempKey |
123 options = s.path.rsplit('?') | |
124 options = options[1].rsplit('&') | |
125 for option in options: | |
126 optionPair = option.rsplit('=') | |
127 if optionPair[0] == "saveFilenamePrefix": | |
128 prefix = optionPair[1] | |
129 if prefix == None: | |
130 prefix = "save" | |
123 s.send_response(200) | 131 s.send_response(200) |
124 s.send_header("Content-type", "application/xml"); | 132 s.send_header("Content-type", "application/xml"); |
125 s.end_headers() | 133 s.end_headers() |
126 reply = "<response><state>OK</state><key>"+key+"</key></response>" | 134 reply = "<response><state>OK</state><key>"+key+"</key></response>" |
127 if sys.version_info[0] == 2: | 135 if sys.version_info[0] == 2: |
128 s.wfile.write(reply) | 136 s.wfile.write(reply) |
129 elif sys.version_info[0] == 3: | 137 elif sys.version_info[0] == 3: |
130 s.wfile.write(bytes(reply, "utf-8")) | 138 s.wfile.write(bytes(reply, "utf-8")) |
131 file = open("../saves/save-"+key+".xml",'w') | 139 file = open("../saves/"+prefix+"-"+key+".xml",'w') |
132 file.write("<waetresult key=\""+key+"\"/>") | 140 file.write("<waetresult key=\""+key+"\"/>") |
133 file.close() | 141 file.close() |
134 | 142 |
135 | 143 |
136 def saveFile(self): | 144 def saveFile(self): |