Exemple #1
0
def connect_signals(**kwargs):
    """
    Listens to the ``initializing`` signal and tells other modules to
    connect their signals. This is done so as to guarantee that django
    is loaded first.
    """
    from labinventory.notifications import email, core, event

    email.connect_signals()
    core.connect_signals()
Exemple #2
0
def setup_logging(**kwargs):
    from logging.config import fileConfig
    import labinventory
    import os.path
    fileConfig(os.path.join(labinventory.__path__[0], "logging.conf"))
    #fileConfig("logging.conf")

def connect_signals():
    from celery import signals
    signals.worker_ready.connect(on_celeryd_init)
    signals.worker_process_init.connect(on_process_worker_init)
    signals.setup_logging.connect(setup_logging) #@UndefinedVariable

connect_signals()
core.connect_signals()
################################################################################

def get_pickleable_exception(exc):
    """Make sure exception is pickleable."""
    try:
        pickle.dumps(deepcopy(exc))
    except Exception:
        return UnpickleableExceptionWrapper.from_exception(exc)
    return exc

def get_populator(asset):
    if asset.type == const.TYPE_F5:
        return populate_f5
    elif asset.type == const.TYPE_PDU:
        return populate_apc_pdu