def recommend_activity_action(): return Factory.instance( 'recommend_activity_action', lambda: RecommendActivityAction(model_factory.activities_service(), model_factory.geojson_formater()))
def snmp_trap_dispatcher(trap_handler): return Factory.instance('snmp_trap_dispatcher', lambda: traps.PySnmpTrapDispatcher(trap_handler, address='0.0.0.0', port=162))
def find_activities_action(): return Factory.instance( 'find_activities_action', lambda: FindActivitiesAction(model_factory.activities_service(), model_factory.geojson_formater()))
def oid_converter(): mibdir = get_mibdir() return Factory.instance('oid_converter', lambda: oid_converter_module.PyOIDConverter( mibdir, modules_from_dir(mibdir)))
# -*- 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)]
def activities_service(): return Factory.instance( 'activities_service', lambda: ActivitiesService(infrastructure_factory. activity_repository()))
def geojson_formater(): return Factory.instance('geojson_formater', lambda: GeoJsonFormater())
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))