Mercurial > caja-test
diff pavement.py @ 4:cf673c093b61 default tip
paver runserver now shows errors if cajoling failed.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 07 Jun 2009 20:44:44 -0700 |
parents | 6737bc744b46 |
children |
line wrap: on
line diff
--- a/pavement.py Sun Jun 07 20:27:26 2009 -0700 +++ b/pavement.py Sun Jun 07 20:44:44 2009 -0700 @@ -19,15 +19,24 @@ if hash not in self.cache: # TODO: This isn't threadsafe. # TODO: There's no way to evict entries from the cache. - output_filename = "output.co.js" - retval = subprocess.call([self.cajoler_path, + cajoled_filename = "output.co.js" + output_filename = "output.txt" + popen = subprocess.Popen([self.cajoler_path, "-i", filename, - "-o", output_filename]) - if retval == 0: - self.cache[hash] = open(output_filename).read() - os.remove(output_filename) + "-o", cajoled_filename], + stdout=open(output_filename, 'w'), + stderr=subprocess.STDOUT) + popen.wait() + if popen.returncode == 0: + content = open(cajoled_filename).read() + self.cache[hash] = Bunch(success = True, + content = content) + os.remove(cajoled_filename) else: - self.cache[hash] = None + output = open(output_filename).read() + self.cache[hash] = Bunch(success = False, + content = output) + os.remove(output_filename) return self.cache[hash] def app(self, env, start_response): @@ -36,14 +45,14 @@ if len(parts) == 1: filename = os.path.join('caja-js', parts[0]) if os.path.exists(filename) and not os.path.isdir(filename): - cajoled = self.cajole(filename) - if cajoled is None: + result = self.cajole(filename) + if not result.success: start_response('500 Internal Server Error', [('Content-type', 'text/plain')]) - return ["Cajoling failed."] + return ["Cajoling failed:\n\n%s" % result.content] start_response('200 OK', [('Content-type', 'text/javascript')]) - return [cajoled] + return [result.content] start_response('404 Not Found', [('Content-type', 'text/plain')]) return ['Not found: %s' % path]