# # # patch "monotone.py" # from [c190085bd22f61eb0b2cff31e5ff45af35503792] # to [7e27870203771c7919ff8cbfc50977f029c16ac7] # # patch "wrapper.py" # from [801e35f2ddfbe6604b69ae4222c4ae6e91f5dbc8] # to [256d3e8f34c5959c8ec24602f639cc0c04e53ae3] # ============================================================ --- monotone.py c190085bd22f61eb0b2cff31e5ff45af35503792 +++ monotone.py 7e27870203771c7919ff8cbfc50977f029c16ac7 @@ -1,5 +1,6 @@ import utility +import syslog import string import urllib import pipes @@ -40,16 +41,19 @@ self.command = "%s --db=%s automate stdio" % (self.mt, pipes.quote(self.dbfile)) self.process = None def __del__(self): + syslog.syslog("%d - stopping automation child" % os.getpid()) if self.process: try: self.process.tochild.close() self.process.fromchild.close() self.process.wait() except: pass + syslog.syslog("%d - completed automation child" % os.getpid()) self.process = None def start(self): self.process = popen2.Popen3(self.command) set_nonblocking(self.process.fromchild) + syslog.syslog("%d - starting automation child" % os.getpid()) def run(self, command, args): if self.process == None: self.start() enc = "l%d:%s" % (len(command), command) @@ -328,3 +332,4 @@ if len(self.result) == self.length: return (self.cmdnum, self.error, self.length, self.is_last, self.result) else: return None + ============================================================ --- wrapper.py 801e35f2ddfbe6604b69ae4222c4ae6e91f5dbc8 +++ wrapper.py 256d3e8f34c5959c8ec24602f639cc0c04e53ae3 @@ -8,6 +8,7 @@ from monotone import Monotone import template import tarfile +import syslog import os import re @@ -98,15 +99,36 @@ uri = req.uri slash = uri.rfind('/') if slash <> -1: uri = uri[slash+1:] + + # + # these handlers don't use PSP, for example if they need + # to return binary or otherwise pristine data to the user + # agent + # if handlers.has_key(uri): return handlers[uri](req) + + # + # if we're here, then we're doing something PSP-ish (or + # it's a 404) + # + rv = apache.HTTP_NOT_FOUND + template = None try: if uri.endswith('.psp') and sane_uri_re.match(uri[:-4]): req.content_type = "text/html" + syslog.syslog("%d - starting template" % os.getpid()) template = psp.PSP(req, filename=uri) template.run() - return apache.OK + syslog.syslog("%d - stopping template" % os.getpid()) + rv = apache.OK + except IOError: + rv = apache.HTTP_INTERNAL_SERVER_ERROR + syslog.syslog("%d - IOError" % os.getpid()) except ValueError: - return apache.HTTP_NOT_FOUND - return apache.HTTP_NOT_FOUND + rv = apache.HTTP_NOT_FOUND + syslog.syslog("%d - ValueError" % os.getpid()) + del template + syslog.syslog("%d - unreffed template" % os.getpid()) + return rv