Example #1
0
def _beginSession(sock, sessionDict):
    # capture the ip & port (or path, for a unix socket)
    # on which the request came, for scoping of configuration
    # data on their basis
    ip, port, unixpath = None, None, None
    try:
        addr = sock.getsockname()
        if type(addr) == types.TupleType:
            ip, port = addr
        else:
            unixpath = addr
    except:
        ERROR("failed to read addr off socket!")
        logException()
        raise

    if ip and port:
        sessionDict[constants.IP] = ip
        sessionDict[constants.PORT] = port
    else:
        sessionDict[constants.UNIXPATH] = unixpath

    # get configuration data for the job
    Configuration.scope(sessionDict)

    # job must be defined, or else die here
    if Configuration.job == None:
        message="No job specified for service on %s:%d, "\
                 "request cannot be processed!" % (ip, port)
        ERROR(message)
        raise SkunkCriticalError, message

    BeginSession(Configuration.job, sock, sessionDict)
Example #2
0
 def __readManifest(self):
     try:
         data=self.__fsclass(self.file).open(os.path.join('/', manifest.MANIFEST_FILE)).read()
     except vfs.VFSException:
         ERROR("error in reading product manifest: %s" % self.file)
         logException()
         raise
     self.manifest=manifest.read_manifest(data)
Example #3
0
def _getClass(fqcn):  # fully qualified class name: package.module.fooClass
    lastDot = fqcn.rfind('.')
    if lastDot == 0:
        raise ValueError, "unable to import %s" % fqcn
    if lastDot > 0:
        modName = fqcn[:lastDot]
        className = fqcn[lastDot + 1:]
        try:
            module = __import__(modName, globals(), locals(), [className])
            return vars(module)[className]
        except (ImportError, AttributeError):
            ERROR("sessionHandler cannot load: unable to import %s!!!!" % fqcn)
            raise
    else:
        raise ValueError, "impossible to import: %s" % fqcn
Example #4
0
def _handleException(connObj):
    text = AE.Error.logException()
    ERROR(text)
    import cStringIO
    connObj.setStatus(500)
    if (hasattr(Configuration, 'errorTemplate')
            and Configuration.errorTemplate):
        connObj.write(
            AE.Component.callComponent(Configuration.errorTemplate, {
                'CONNECTION': connObj,
                'ERROR_TEXT': text
            }))
        return connObj.response()
    connObj._output = cStringIO.StringIO(text)
    connObj.responseHeaders['Content-Type'] = 'text/plain'
    return connObj.response()
Example #5
0
def SIGALRMHandler(*args):
    Configuration.trim()
    ERROR('Throwing timeout exception')
    signal.alarm(1)  # in case they catch this exception
    raise DocumentTimeout, "timeout reached"