summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-04 19:10:35 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-04 19:10:35 +0000
commit20e995e05dfa0e13ba24cec831e1e5b9c17dd9cb (patch)
treee77bb7ef911751d7de942c2d9c3ea411940e2c73
parentc9d742a76fa0b63760d22cae690887b2af51ca80 (diff)
downloadmorph-cache-server-20e995e05dfa0e13ba24cec831e1e5b9c17dd9cb.tar.gz
Working again but without forms
-rwxr-xr-xmorph-cache-server28
1 files changed, 16 insertions, 12 deletions
diff --git a/morph-cache-server b/morph-cache-server
index 25ae139..e633d90 100755
--- a/morph-cache-server
+++ b/morph-cache-server
@@ -23,6 +23,7 @@ import logging
import os
import urllib
import urllib2
+import urlparse
import shutil
from bottle import Bottle, request, response, run, static_file
@@ -307,24 +308,27 @@ class MorphCacheServer(cliapp.Application):
@app.post('/artifacts')
def post_artifacts():
#artifacts = request.forms.get('artifacts').split(',')
- artifacts = request.body.read()
+
+ # TODO: we probably ought to figure out why this is being
+ # returned as a list
+ artifacts = urlparse.parse_qs(request.body.read())['artifacts'][0].split(',')
logging.debug(artifacts)
- #results = {}
+ results = {}
- #logging.debug('Received a POST request for /artifacts')
+ logging.debug('Received a POST request for /artifacts')
- #for artifact in artifacts:
- # logging.debug('Checking whether artifact %s is in the cache'
- # % artifact)
- # basename = self._unescape_parameter(artifact)
- # filename = os.path.join(self.settings['artifact-dir'], basename)
+ for artifact in artifacts:
+ logging.debug('Checking whether artifact %s is in the cache'
+ % artifact)
+ basename = self._unescape_parameter(artifact)
+ filename = os.path.join(self.settings['artifact-dir'], basename)
- # results[artifact] = os.path.exists(filename)
- # logging.debug('%s is%s in the cache' %
- # (artifact, '' if result[artifact] else "n't"))
+ results[artifact] = os.path.exists(filename)
+ logging.debug('%s is%s in the cache' %
+ (artifact, '' if results[artifact] else "n't"))
- #return results
+ return results
root = Bottle()
root.mount(app, '/1.0')