How to use the twisted.python.log.err function in Twisted

To help you get started, we’ve selected a few Twisted examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CouchPotato / CouchPotatoServer / libs / pyutil / iputil.py View on Github external
else:
                # this one works on OS-X (bsd), and gives us 10240, but
                # it doesn't work on linux (on which both the hard and
                # soft limits are set to 1024 by default).
                resource.setrlimit(resource.RLIMIT_NOFILE, (-1,-1))
                new = resource.getrlimit(resource.RLIMIT_NOFILE)
                if new[0] == current[0]:
                    # probably cygwin, which ignores -1. Use a real value.
                    resource.setrlimit(resource.RLIMIT_NOFILE, (3200,-1))

        except ValueError:
            log.msg("unable to set RLIMIT_NOFILE: current value %s"
                     % (resource.getrlimit(resource.RLIMIT_NOFILE),))
        except:
            # who knows what. It isn't very important, so log it and continue
            log.err()
except ImportError:
github twisted / twisted / src / twisted / internet / iocpreactor / tcp.py View on Github external
def readConnectionLost(self, reason):
        p = interfaces.IHalfCloseableProtocol(self.protocol, None)
        if p:
            try:
                p.readConnectionLost()
            except:
                log.err()
                self.connectionLost(failure.Failure())
        else:
            self.connectionLost(reason)
github StarlitGhost / PyMoronBot / twisted / web / _newclient.py View on Github external
def ebProducing(err):
                if state == [None]:
                    # The producing Deferred failed first.  This means the
                    # overall writeTo Deferred is going to errback now.
                    # Tell the encoder that we're done so it knows to reject
                    # further writes from the producer (which should not
                    # happen, but the producer may be buggy).
                    state[0] = 3
                    encoder._allowNoMoreWrites()
                    ultimate.errback(err)
                else:
                    # The producing Deferred failed after the consuming
                    # Deferred failed.  It shouldn't have, so it's buggy.
                    # Log the exception in case anyone who can fix the code
                    # is watching.
                    log.err(err, "Producer is buggy")
github gtaylor / dockerized-image-crawler / crawler / webapi_service / resources / job_submission.py View on Github external
def _handle_error(self, err, request):
        exc = err.trap(ValueError)
        if exc == ValueError:
            request.setResponseCode(400)
            error_json = json.dumps({
                'message': exc.message,
            })
        else:
            log.err("Error encountered when creating new job.")
            log.err(exc)

            request.setResponseCode(500)
            error_json = json.dumps({
                    'message': "An error was encountered while creating new job.",
            }, cls=JobDataEncoder)

        request.setHeader('Content-Type', 'application/json')
        request.write(error_json)
        request.finish()
github richardingham / octopus / octopus / manufacturer / harvard.py View on Github external
def monitor ():
			return defer.gatherResults([
				self.protocol.write(self.pumpNumber + "RAT").addCallback(interpret_rate).addErrback(log.err),
				self.protocol.write(self.pumpNumber + "DEL").addCallback(interpret_delivered).addErrback(log.err),
				self.protocol.write(self.pumpNumber + "TGT").addCallback(interpret_target).addErrback(log.err)
			])
github praekeltfoundation / vumi / vumi / service.py View on Github external
def _read_messages(self):
        try:
            while self.keep_consuming:
                message = yield self.queue.get()
                if isinstance(message, QueueCloseMarker):
                    break
                if self.paused:
                    yield self._unpause_d
                yield self.consume(message)
        except txamqp.queue.Closed as e:
            log.err("Queue has closed", e)
        except Exception:
            # Log this explicitly instead of waiting for the deferred to be
            # garbage-collected, because that might only happen later on pypy.
            log.err()
github twisted / twisted / src / twisted / words / xish / utility.py View on Github external
        @note: Exceptions raised by callbacks are trapped and logged. They will
               not propagate up to make sure other callbacks will still be
               called, and the event dispatching always succeeds.

        @param args: Positional arguments to the callable.
        @type args: C{list}
        @param kwargs: Keyword arguments to the callable.
        @type kwargs: C{dict}
        """

        for key, (methodwrapper, onetime) in list(self.callbacks.items()):
            try:
                methodwrapper(*args, **kwargs)
            except:
                log.err()

            if onetime:
                del self.callbacks[key]
github Electrostatics / apbs-pdb2pqr / pdb2pqr / ZSI / twisted / WSresource.py View on Github external
def processRequest(cls, ps, **kw):
        """invokes callback that should return a (request,response) tuple.
        representing the SOAP request and response respectively.
        ps -- ParsedSoap instance representing HTTP Body.
        request -- twisted.web.server.Request
        """
        resource = kw['resource']
        request = kw['request']
        method =  getattr(resource, 'soap_%s' %
                           _get_element_nsuri_name(ps.body_root)[-1])
                                              
        try:
            req_pyobj,rsp_pyobj = method(ps, request=request)
        except (TypeError, ex):
            log.err(
                'ERROR: service %s is broken, method MUST return request, response'\
                    % cls.__name__
            )
            raise
        except (Exception, ex):
            log.err('failure when calling bound method')
            raise
        
        return rsp_pyobj
github PyMamba / mamba-framework / mamba / deployment / fabric_deployer.py View on Github external
:plarform: Unix, Windows
    :synopsis: Fabric plugin for Mamba deployer.

.. moduleauthor:: Oscar Campos 
"""

import sys

from twisted.python import log, filepath

try:
    from fabric import state
    from fabric.tasks import execute
    from fabric import main as fabric_main
except ImportError:
    log.err('Fabric is not installed on this system')
    raise  # propagate

from mamba.deployment import deployer
from mamba.utils.filevariables import FileVariables


class FabricMissingConfigFile(deployer.DeployerError):
    """Fired when missing config file is detected
    """


class FabricConfigFileDontExists(deployer.DeployerError):
    """Fired when the config file does not exists
    """

github opennode / opennode-management / opennode / oms / endpoint / ssh / protocol.py View on Github external
def wrapper(self, *args, **kwargs):
        try:
            old_sub_protocol = self.sub_protocol
            if not old_sub_protocol:
                self.sub_protocol = CallbackExecutionSubProtocol()

            yield defer.inlineCallbacks(fun)(self, *args, **kwargs)
        except Exception as e:
            log.msg("got exception while %s: %s" % (fun, e), system='protocol')
            if get_config().getboolean('debug', 'print_exceptions'):
                log.err(system='protocol')

        execution_sub_protocol = self.sub_protocol
        self.sub_protocol = old_sub_protocol
        for (key, mod) in execution_sub_protocol.buffer:
            if key not in self.keyHandlers.keys():
                self.keystrokeReceived(key, mod)