示例#1
0
def recommend_activity_action():
    return Factory.instance(
        'recommend_activity_action',
        lambda: RecommendActivityAction(model_factory.activities_service(),
                                        model_factory.geojson_formater()))
示例#2
0
def snmp_trap_dispatcher(trap_handler):
    return Factory.instance('snmp_trap_dispatcher', lambda:
            traps.PySnmpTrapDispatcher(trap_handler, address='0.0.0.0',
                port=162))
示例#3
0
def find_activities_action():
    return Factory.instance(
        'find_activities_action',
        lambda: FindActivitiesAction(model_factory.activities_service(),
                                     model_factory.geojson_formater()))
示例#4
0
def oid_converter():
    mibdir = get_mibdir()
    return Factory.instance('oid_converter',
                            lambda: oid_converter_module.PyOIDConverter(
                            mibdir,
                            modules_from_dir(mibdir)))
示例#5
0
# -*- coding: utf-8 -*-

import glob
import os.path

import os
from infcommon import Factory
from infsnmp import (
    clients,
    types,
    oid_converter as oid_converter_module,
    traps
)

snmp_client = lambda: Factory.instance(
    'snmp_client', lambda: clients.PySnmpClient())

snmp_types = lambda: Factory.instance(
    'snmp_types', lambda: types.PySnmpTypes())


def get_mibdir():
    return os.environ.get('MIBDIR', '/etc/felix/snmp/pymibs/')


def get_mib_modules():
    return [value for value in os.environ.get('MIBMODULES', '').split(':') if value]


def modules_from_dir(directory):
    return [os.path.basename(f).split('.')[0] for f in glob.glob('%s/*.py' % directory)]
示例#6
0
def activities_service():
    return Factory.instance(
        'activities_service', lambda: ActivitiesService(infrastructure_factory.
                                                        activity_repository()))
示例#7
0
def geojson_formater():
    return Factory.instance('geojson_formater', lambda: GeoJsonFormater())
示例#8
0
def activity_repository():
    json_file_path = '{base_path}/{file_name}'.format(base_path=BASE_PATH,
                                                      file_name=FILE_NAME)
    return Factory.instance(
        'activity_repository',
        lambda: LoadFromFileActivityRepository(file_path=json_file_path))