本文整理汇总了Python中simport.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
super(Alarming, self).__init__()
self.events_message_queue = simport.load(cfg.CONF.messaging.driver)("events")
self.alarm_state_transitions_message_queue = simport.load(cfg.CONF.messaging.driver)("alarm-state-transitions")
示例2: launch
def launch(conf, config_file="/etc/monasca/events_api.conf"):
log.register_options(cfg.CONF)
log.set_defaults()
cfg.CONF(args=[],
project='monasca_events_api',
default_config_files=[config_file])
log.setup(cfg.CONF, 'monasca_events_api')
app = falcon.API()
versions = simport.load(cfg.CONF.dispatcher.versions)()
app.add_route("/", versions)
app.add_route("/{version_id}", versions)
events = simport.load(cfg.CONF.dispatcher.events)()
app.add_route("/v2.0/events", events)
app.add_route("/v2.0/events/{event_id}", events)
streams = simport.load(cfg.CONF.dispatcher.stream_definitions)()
app.add_route("/v2.0/stream-definitions/", streams)
app.add_route("/v2.0/stream-definitions/{stream_id}", streams)
transforms = simport.load(cfg.CONF.dispatcher.transforms)()
app.add_route("/v2.0/transforms", transforms)
app.add_route("/v2.0/transforms/{transform_id}", transforms)
LOG.debug('Dispatcher drivers have been added to the routes!')
return app
示例3: test_good_load_local
def test_good_load_local(self):
method = simport.load("tests|"
"localmodule:Foo.method_a")
import localmodule
self.assertEquals(method, localmodule.Foo.method_a)
self.assertEquals(localmodule.function_a,
simport.load("localmodule:function_a"))
示例4: __init__
def __init__(self):
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._message_queue = (
simport.load(cfg.CONF.messaging.driver)("transform-definitions"))
self._transforms_repo = (
simport.load(cfg.CONF.repositories.transforms)())
示例5: __init__
def __init__(self, alarm_ttl, config):
self._alarm_ttl = alarm_ttl
self._statsd = monascastatsd.Client(name='monasca',
dimensions=BaseProcessor.dimensions)
if 'database' in config and 'repo_driver' in config['database']:
self._db_repo = simport.load(config['database']['repo_driver'])(config)
else:
self._db_repo = simport.load('monasca_notification.common.repositories.mysql.mysql_repo:MysqlRepo')(config)
示例6: __init__
def __init__(self):
self._region = cfg.CONF.region
self._default_authorized_roles = cfg.CONF.security.default_authorized_roles
self._delegate_authorized_roles = cfg.CONF.security.delegate_authorized_roles
self._post_events_authorized_roles = (
cfg.CONF.security.default_authorized_roles + cfg.CONF.security.agent_authorized_roles
)
self._message_queue = simport.load(cfg.CONF.messaging.driver)("raw-events")
self._events_repo = simport.load(cfg.CONF.repositories.events)()
示例7: __init__
def __init__(self):
try:
super(AlarmsStateHistory, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._alarms_repo = simport.load(
cfg.CONF.repositories.alarms_driver)()
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
示例8: __init__
def __init__(self):
super(Notifications, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = cfg.CONF.security.default_authorized_roles
self._notifications_repo = simport.load(cfg.CONF.repositories.notifications_driver)()
示例9: __init__
def __init__(self, **kwargs):
super(CallbackList, self).__init__(**kwargs)
self.callbacks = []
self.config = kwargs
callback_str = self.config.get('callback_list', "")
callback_str_list = [x.strip() for x in callback_str.split(",")]
self.callbacks = [simport.load(c)(**self.config)
for c in callback_str_list]
示例10: __init__
def __init__(self, app=None, queue_name=None):
super(ShoeboxHandler, self).__init__(app, queue_name)
# Don't use interpolation from ConfigParser ...
self.config = dict(yagi.config.config.items('shoebox', raw=True))
roll_checker_str = self.config['roll_checker']
self.roll_checker = simport.load(roll_checker_str)(**self.config)
self.working_directory = self.config.get('working_directory', '.')
self.destination_folder = self.config.get('destination_folder', '.')
for d in [self.working_directory, self.destination_folder]:
if not os.path.isdir(d):
os.makedirs(d)
template=self.config.get('filename_template',
'events_%Y_%m_%d_%X_%f.dat')
cb = simport.load(self.config['callback'])(**self.config)
self.roll_manager = roll_manager.WritingRollManager(template,
self.roll_checker, self.working_directory,
archive_callback=cb)
示例11: launch
def launch(conf, config_file="/etc/monasca/api-config.conf"):
log.register_options(cfg.CONF)
log.set_defaults()
cfg.CONF(args=[],
project='monasca_api',
default_config_files=[config_file])
log.setup(cfg.CONF, 'monasca_api')
app = falcon.API()
versions = simport.load(cfg.CONF.dispatcher.versions)()
app.add_route("/", versions)
app.add_route("/{version_id}", versions)
metrics = simport.load(cfg.CONF.dispatcher.metrics)()
app.add_route("/v2.0/metrics", metrics)
metrics_measurements = simport.load(
cfg.CONF.dispatcher.metrics_measurements)()
app.add_route("/v2.0/metrics/measurements", metrics_measurements)
metrics_statistics = simport.load(cfg.CONF.dispatcher.metrics_statistics)()
app.add_route("/v2.0/metrics/statistics", metrics_statistics)
metrics_names = simport.load(cfg.CONF.dispatcher.metrics_names)()
app.add_route("/v2.0/metrics/names", metrics_names)
alarm_definitions = simport.load(cfg.CONF.dispatcher.alarm_definitions)()
app.add_route("/v2.0/alarm-definitions/", alarm_definitions)
app.add_route("/v2.0/alarm-definitions/{alarm_definition_id}",
alarm_definitions)
alarms = simport.load(cfg.CONF.dispatcher.alarms)()
app.add_route("/v2.0/alarms", alarms)
app.add_route("/v2.0/alarms/{alarm_id}", alarms)
alarms_state_history = simport.load(
cfg.CONF.dispatcher.alarms_state_history)()
app.add_route("/v2.0/alarms/state-history", alarms_state_history)
app.add_route("/v2.0/alarms/{alarm_id}/state-history",
alarms_state_history)
notification_methods = simport.load(
cfg.CONF.dispatcher.notification_methods)()
app.add_route("/v2.0/notification-methods", notification_methods)
app.add_route("/v2.0/notification-methods/{notification_method_id}",
notification_methods)
LOG.debug('Dispatcher drivers have been added to the routes!')
return app
示例12: __init__
def __init__(self):
try:
super(Metrics, self).__init__()
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._delegate_authorized_roles = (
cfg.CONF.security.delegate_authorized_roles)
self._post_metrics_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.agent_authorized_roles)
self._message_queue = simport.load(cfg.CONF.messaging.driver)(
'metrics')
self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)()
except Exception as ex:
LOG.exception(ex)
raise falcon.HTTPInternalServerError('Service unavailable',
ex.message)
示例13: __init__
def __init__(self):
try:
self._region = cfg.CONF.region
self._default_authorized_roles = (
cfg.CONF.security.default_authorized_roles)
self._delegate_authorized_roles = (
cfg.CONF.security.delegate_authorized_roles)
self._post_authorized_roles = (
cfg.CONF.security.default_authorized_roles +
cfg.CONF.security.agent_authorized_roles)
self._stream_definitions_repo = (
simport.load(cfg.CONF.repositories.streams)())
self.stream_definition_event_message_queue = (
simport.load(cfg.CONF.messaging.driver)('stream-definitions'))
except Exception as ex:
LOG.exception(ex)
raise exceptions.RepositoryException(ex)
示例14: test_good_load_external
def test_good_load_external(self):
method = simport.load("tests/external|"
"external.externalmodule:Blah.method_b")
self.assertTrue('external.externalmodule' in sys.modules)
old = sys.modules['external.externalmodule']
import external.externalmodule
self.assertEqual(external.externalmodule,
sys.modules['external.externalmodule'])
self.assertEqual(old, external.externalmodule)
self.assertEqual(method, external.externalmodule.Blah.method_b)
示例15: __init__
def __init__(self, app=None, queue_name=None):
super(ShoeboxHandler, self).__init__(app, queue_name)
# Don't use interpolation from ConfigParser ...
self.config = dict(yagi.config.config.items('shoebox', raw=True))
roll_checker_str = self.config.get('roll_checker')
self.roll_checker = None
if roll_checker_str:
self.roll_checker = simport.load(roll_checker_str)(**self.config)
self.working_directory = self.config.get('working_directory', '.')
self.destination_folder = self.config.get('destination_folder', '.')
for d in [self.working_directory, self.destination_folder]:
if not os.path.isdir(d):
os.makedirs(d)
template=self.config.get('filename_template',
'events_%Y_%m_%d_%X_%f.dat')
callback_str = self.config.get('callback')
cb = None
if callback_str:
cb = simport.load(callback_str)(**self.config)
roll_manager_str = self.config.get('roll_manager',
'shoebox.roll_manager:WritingRollManager')
self.wrap_payload_with_region = self.config.get(
'wrap_payload_with_region', 'False') == 'True'
self.region = self.config.get('wrap_region', 'n/a')
self.cell = self.config.get('wrap_cell', 'n/a')
# Hack(sandy): These sorts of parameters should be left to the
# callback handlers. Just need it here to get over the hump.
# Needs to be refactored.
roll_size_mb = self.config.get('roll_size_mb', 1000)
self.roll_manager = simport.load(roll_manager_str)(template,
self.roll_checker, directory=self.working_directory,
destination_directory=self.destination_folder,
archive_callback=cb, roll_size_mb=roll_size_mb)