Exemplo n.º 1
0
 def problem(f):
     log.err(f,
             "error in hint_to_endpoint",
             level=UNUSUAL,
             facility="foolscap.connection",
             umid="Fxtg6A")
     # this hint will be ignored
     return f
Exemplo n.º 2
0
 def _service_startup_failed(self, failure):
     self.log('_startService() failed')
     log.err(failure)
     print "Node._startService failed, aborting"
     print failure
     #reactor.stop() # for unknown reasons, reactor.stop() isn't working.  [ ] TODO
     self.log('calling os.abort()')
     twlog.msg('calling os.abort()') # make sure it gets into twistd.log
     print "calling os.abort()"
     os.abort()
Exemplo n.º 3
0
 def _service_startup_failed(self, failure):
     self.log('_startService() failed')
     log.err(failure)
     print "Node._startService failed, aborting"
     print failure
     #reactor.stop() # for unknown reasons, reactor.stop() isn't working.  [ ] TODO
     self.log('calling os.abort()')
     twlog.msg('calling os.abort()') # make sure it gets into twistd.log
     print "calling os.abort()"
     os.abort()
Exemplo n.º 4
0
 def write_config_file(self, name, value, mode="w"):
     """
     writes the given 'value' into a file called 'name' in the config
     directory
     """
     fn = os.path.join(self._basedir, name)
     try:
         fileutil.write(fn, value, mode)
     except EnvironmentError:
         log.err(
             Failure(),
             "Unable to write config file '{}'".format(fn),
         )
Exemplo n.º 5
0
 def write_config_file(self, name, value, mode="w"):
     """
     writes the given 'value' into a file called 'name' in the config
     directory
     """
     fn = os.path.join(self._basedir, name)
     try:
         fileutil.write(fn, value, mode)
     except EnvironmentError:
         log.err(
             Failure(),
             "Unable to write config file '{}'".format(fn),
         )
Exemplo n.º 6
0
 def _connectionFailed(self, reason, hint, lp):
     # this is called if some individual TCP connection cannot be
     # established
     if reason.check(error.ConnectionRefusedError):
         description = "connection refused"
         self.log("connection refused for %s" % hint,
                  level=OPERATIONAL,
                  parent=lp,
                  umid="rSrUxQ")
     elif reason.check(error.ConnectingCancelledError,
                       defer.CancelledError):
         description = "abandoned"
         self.log("abandoned attempt to %s" % hint,
                  level=OPERATIONAL,
                  parent=lp,
                  umid="CC8vwg")
     elif reason.check(InvalidHintError):
         description = "bad hint: %s" % str(reason.value)
         self.log("unable to use hint: %s: %s" % (hint, reason.value),
                  level=UNUSUAL,
                  parent=lp,
                  umid="z62ctA")
     else:
         # some errors, like txsocksx.errors.ServerFailure, extend
         # Exception without defining a __str__, so when one is
         # constructed without arguments, their str() is empty, which is
         # not very useful. Their repr() at least includes the exception
         # name. In general, str() is better than repr(), since it lets
         # the exception designer build a human-meaningful string, so
         # we'll prefer str() unless it's empty.
         why = str(reason.value) or repr(reason.value)
         description = "failed to connect: %s" % why
         log.err(reason,
                 "failed to connect to %s" % hint,
                 level=CURIOUS,
                 parent=lp,
                 facility="foolscap.connection",
                 umid="2PEowg")
     suffix = getattr(reason.value,
                      "foolscap_connection_handler_error_suffix", None)
     if suffix:
         description += suffix
     self._connectionInfo._set_connection_status(hint, description)
     if not self.failureReason:
         self.failureReason = reason
     self.checkForFailure()
     self.checkForIdle()
Exemplo n.º 7
0
 def _connectionFailed(self, reason, hint, lp):
     # this is called if some individual TCP connection cannot be
     # established
     if reason.check(error.ConnectionRefusedError):
         self.log("connection refused for %s" % hint, level=OPERATIONAL,
                  parent=lp, umid="rSrUxQ")
     elif reason.check(error.ConnectingCancelledError):
         self.log("abandoned attempt to %s" % hint, level=OPERATIONAL,
                  parent=lp, umid="CC8vwg")
     elif reason.check(InvalidHintError):
         self.log("unable to use hint: %s: %s" % (hint, reason.value),
                  level=UNUSUAL, parent=lp, umid="z62ctA")
     else:
         log.err(reason, "failed to connect to %s" % hint, level=CURIOUS,
                 parent=lp, facility="foolscap.connection",
                 umid="2PEowg")
     if not self.failureReason:
         self.failureReason = reason
     self.checkForFailure()
     self.checkForIdle()
Exemplo n.º 8
0
    def fail(self, why):
        if self.active:
            if self.broker:
                self.broker.removeRequest(self)
            self.active = False
            self.failure = why
            if (self.broker and self.broker.tub
                    and self.broker.tub.logRemoteFailures):

                my_short_tubid = "??"
                if self.broker.tub:  # for tests
                    my_short_tubid = self.broker.tub.getShortTubID()
                their_short_tubid = self.broker.remote_tubref.getShortTubID()

                lp = log.msg("an outbound callRemote (that we [%s] sent to "
                             "someone else [%s]) failed on the far end" %
                             (my_short_tubid, their_short_tubid),
                             level=log.UNUSUAL)
                methname = ".".join(
                    [self.interfaceName or "?", self.methodName or "?"])
                log.msg(" reqID=%d, rref=%s, methname=%s" %
                        (self.reqID, self.rref, methname),
                        level=log.NOISY,
                        parent=lp)
                #stack = why.getTraceback()
                # TODO: include the first few letters of the remote tubID in
                # this REMOTE tag
                #stack = "REMOTE: " + stack.replace("\n", "\nREMOTE: ")
                log.msg(" the REMOTE failure was:",
                        failure=why,
                        level=log.NOISY,
                        parent=lp)
                #log.msg(stack, level=log.NOISY, parent=lp)
            self.deferred.errback(why)
        else:
            log.msg("WEIRD: fail() on an inactive request", traceback=True)
            if self.failure:
                log.msg("multiple failures")
                log.msg("first one was:", self.failure)
                log.msg("this one was:", why)
                log.err("multiple failures indicate a problem")
Exemplo n.º 9
0
    def fail(self, why):
        if self.active:
            if self.broker:
                self.broker.removeRequest(self)
            self.active = False
            self.failure = why
            if (self.broker and
                self.broker.tub and
                self.broker.tub.logRemoteFailures):

                my_short_tubid = "??"
                if self.broker.tub: # for tests
                    my_short_tubid = self.broker.tub.getShortTubID()
                their_short_tubid = self.broker.remote_tubref.getShortTubID()

                lp = log.msg("an outbound callRemote (that we [%s] sent to "
                             "someone else [%s]) failed on the far end"
                             % (my_short_tubid, their_short_tubid),
                             level=log.UNUSUAL)
                methname = ".".join([self.interfaceName or "?",
                                     self.methodName or "?"])
                log.msg(" reqID=%d, rref=%s, methname=%s"
                        % (self.reqID, self.rref, methname),
                        level=log.NOISY, parent=lp)
                #stack = why.getTraceback()
                # TODO: include the first few letters of the remote tubID in
                # this REMOTE tag
                #stack = "REMOTE: " + stack.replace("\n", "\nREMOTE: ")
                log.msg(" the REMOTE failure was:", failure=why,
                        level=log.NOISY, parent=lp)
                #log.msg(stack, level=log.NOISY, parent=lp)
            self.deferred.errback(why)
        else:
            log.msg("WEIRD: fail() on an inactive request", traceback=True)
            if self.failure:
                log.msg("multiple failures")
                log.msg("first one was:", self.failure)
                log.msg("this one was:", why)
                log.err("multiple failures indicate a problem")
Exemplo n.º 10
0
 def _connectionFailed(self, reason, hint, lp):
     # this is called if some individual TCP connection cannot be
     # established
     if reason.check(error.ConnectionRefusedError):
         description = "connection refused"
         self.log("connection refused for %s" % hint, level=OPERATIONAL,
                  parent=lp, umid="rSrUxQ")
     elif reason.check(error.ConnectingCancelledError, defer.CancelledError):
         description = "abandoned"
         self.log("abandoned attempt to %s" % hint, level=OPERATIONAL,
                  parent=lp, umid="CC8vwg")
     elif reason.check(InvalidHintError):
         description = "bad hint: %s" % str(reason.value)
         self.log("unable to use hint: %s: %s" % (hint, reason.value),
                  level=UNUSUAL, parent=lp, umid="z62ctA")
     else:
         # some errors, like txsocksx.errors.ServerFailure, extend
         # Exception without defining a __str__, so when one is
         # constructed without arguments, their str() is empty, which is
         # not very useful. Their repr() at least includes the exception
         # name. In general, str() is better than repr(), since it lets
         # the exception designer build a human-meaningful string, so
         # we'll prefer str() unless it's empty.
         why = str(reason.value) or repr(reason.value)
         description = "failed to connect: %s" % why
         log.err(reason, "failed to connect to %s" % hint, level=CURIOUS,
                 parent=lp, facility="foolscap.connection",
                 umid="2PEowg")
     suffix = getattr(reason.value,
                      "foolscap_connection_handler_error_suffix",
                      None)
     if suffix:
         description += suffix
     self._connectionInfo._set_connection_status(hint, description)
     if not self.failureReason:
         self.failureReason = reason
     self.checkForFailure()
     self.checkForIdle()
Exemplo n.º 11
0
def err(failure=None, _why=None, **kwargs):
    tw_log.err(failure, _why, **kwargs)
    if 'level' not in kwargs:
        kwargs['level'] = log.UNUSUAL
    return log.err(failure, _why, **kwargs)
Exemplo n.º 12
0
def err(failure=None, _why=None, **kwargs):
    tw_log.err(failure, _why, **kwargs)
    if 'level' not in kwargs:
        kwargs['level'] = log.UNUSUAL
    return log.err(failure, _why, **kwargs)
Exemplo n.º 13
0
def err(failure=None, _why=None, **kwargs):
    tw_log.err(failure, _why, **kwargs)
    if 'level' not in kwargs:
        kwargs['level'] = log.UNUSUAL
    return log.err(failure, _why, **bytes_to_unicode(True, kwargs))