Example #1
0
if "runqueueserver" in setproctitle.getproctitle():
    logger_name = "signalqueue > WORKER"

try:
    from jogging import logging as logg
except ImportError:
    try:
        import logging
    except ImportError:
        print("WTF: You have no logging facilities available whatsoever.")
        print("I'm initializing a fake logger class. Love, django-signalqueue.")
        # set up fake logger
        logg = FakeLogger()
    else:
        logg = logging.getLogger(logger_name)
        logg.setLevel(logging.DEBUG)

from contextlib import contextmanager


@contextmanager
def log_exceptions(exc_type=Exception, **kwargs):
    try:
        from raven.contrib.django.models import client as raven_client
    except ImportError:
        raven_client = None
    try:
        yield
    except exc_type, exc:
        if raven_client is not None:
            raven_client.captureException(sys.exc_info())
Example #2
0
    logger_name = "signalqueue > WORKER"

try:
    from jogging import logging as logg
except ImportError:
    try:
        import logging
    except ImportError:
        print("WTF: You have no logging facilities available whatsoever.")
        print(
            "I'm initializing a fake logger class. Love, django-signalqueue.")
        # set up fake logger
        logg = FakeLogger()
    else:
        logg = logging.getLogger(logger_name)
        logg.setLevel(logging.DEBUG)

from contextlib import contextmanager


@contextmanager
def log_exceptions(exc_type=Exception, **kwargs):
    try:
        from raven.contrib.django.models import client as raven_client
    except ImportError:
        raven_client = None
    try:
        yield
    except exc_type, exc:
        if raven_client is not None:
            raven_client.captureException(sys.exc_info())
Example #3
0
        for fname in ('critical', 'debug', 'error', 'exception', 'info', 'warning'):
            setattr(self, fname, self.logg)


try:
    from jogging import logging as logg
except ImportError:
    try:
        import logging
    except ImportError:
        print "WTF: You have no logging facilities available whatsoever -- initializing a fake logger class. Love, django-signalqueue."
        # set up fake logger
        logg = FakeLogger()
    else:
        logg = logging.getLogger("signalqueue")
        logg.setLevel(logging.INFO)

class ADict(dict):
    """
    ADict -- Convenience class for dictionary key access via attributes.
    
    The 'A' in 'ADict' is for 'Access' -- you can also use adict.key as well as adict[key]
    to access hash values.
    
    """
    def __init__(self, *args, **kwargs):
        dict.__init__(self, *args, **kwargs)
    
    def __getattr__(self, name):
        if name in self:
            return self[name]