本文整理汇总了Python中settings.settings_base.SettingsBase.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python SettingsBase.__init__方法的具体用法?Python SettingsBase.__init__怎么用?Python SettingsBase.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.settings_base.SettingsBase
的用法示例。
在下文中一共展示了SettingsBase.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, name, core_services, settings, properties):
self._name = name
self._core = core_services
self._tracer = get_tracer(name)
# Initialize settings:
## Settings Table Definition:
settings_list = [
Setting(
name='trace', type=str, required=False,
default_value=self.DEF_TRACE),
]
# Add our settings_list entries into the settings passed to us.
settings = self.merge_settings(settings, settings_list)
self.__settings = settings
SettingsBase.__init__(self, binding=("devices", (name,), "settings"),
setting_defs=settings)
# Initialize properties:
self.__properties = { }
for property in properties:
self.add_property(property)
# pre_start - check if special trace level requested
trace = SettingsBase.get_setting(self, "trace")
try:
self._tracer.set_level(trace)
except:
self._tracer.warning("Ignoring bad trace level \'%s\' for this device", trace)
self._tracer.calls("DeviceBase.__init__()")
示例2: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, settings_flo, settings_filename):
# Provides self.settings and serialization:
settings_list = [
Setting(
name='devices', type=list, required=False, default_value=[]),
Setting(
name='loggers', type=list, required=False, default_value=[]),
Setting(
name='presentations', type=list, required=False,
default_value=[]),
Setting(
name='services', type=list, required=False, default_value=[]),
Setting(
name='tracing', type=list, required=False, default_value=[]),
]
SettingsBase.__init__(self, binding=(), setting_defs=settings_list)
self.__settings_filename = settings_filename
self.__service_map = {}
self.__serializer_ext_map = {}
self.__sleep_req = None # STUB: seconds to wait before power-off
self.__shutdown_event = threading.Event()
# TODO: core may become a thread so we can monitor services and
# attempt to restart them when they fail.
try:
self.epoch(settings_flo)
except KeyboardInterrupt: # pragma: no cover
raise KeyboardInterrupt
except CoreSettingsException:
print "Core: Initial settings invalid, aborting start up..."
sys.exit()
except:
print "Core: Fatal exception caught! Halting execution."
self.request_shutdown()
示例3: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, name, settings_list):
"""Create a presentation instance, given a name and settings list."""
self.__name = name
## Initialize settings:
SettingsBase.__init__(self,
binding=('presentations', (name,), 'settings'),
setting_defs=settings_list)
示例4: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, parent, channel, tag):
"""\
Create a new :class:`Annotation`
parent
:class:`ValueService` instance managing this object
channel
Channel name of channel this annotation will act upon.
tag
name to place in :class:`AnnotatedSample` set if
annotation needs to occur
:class:`Annotation` objects inherit from :class:`SettingsBase`
with a binding beneath that of the parent
:class:`ValueService` and take the following settings.
Settings
expr (required)
Python expression that must evaluate to a boolean.
When true, the `tag` will be annotated on the
:class:`AnnotatedSample` object. The sample object
will be available as the symbol `sample.
error (optional, default: True)
Boolean value that determines the set to annotate
within. On `True` the `tag` will be placed in the
`errors` set. It will be placed in `other` on `False`
"""
self._parent = parent
self._channel_name = channel
self._tag_name = tag
settings_list = [
Setting(
name='expr', type=str, required=True),
Setting(
name='error', type=bool, required=False,
default_value=True),
]
# Use parent binding to create our own child binding
SettingsBase.__init__(self,
binding=parent._settings_binding + \
((channel,),
'checks',
(tag,),
'definition'),
setting_defs=settings_list)
示例5: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, name, core_services, settings, properties):
self.__name = name
self.__settings = settings
self.__core = core_services
self.__properties = { }
from core.tracing import get_tracer
self.__tracer = get_tracer(name)
# Initialize settings:
SettingsBase.__init__(self, binding=("devices", (name,), "settings"),
setting_defs=settings)
# Initialize properties:
for property in properties:
self.add_property(property)
示例6: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, core, settings_binding, additional_settings=None):
"""
Creates a new :class:`AbstractServiceManager` instance.
`core` must be a reference to the core service manager
(see :mod:`~src.core.core_services`).
`settings_binding` must be a valid settings binding tuple. This
determines at what point in the settings registry the service
will locate and receive its settings. If we wished to create a
service manager which received its settings in a binding off the
registry root called "devices" the `settings_binding` would be
given as a one element tuple ('devices',).
`additional_settings` is a list of :class:`Setting` objects
which define additional settings, aside from the implied instance
list that all :class:`AbstractServiceManager` instances have.
"""
if additional_settings == None:
additional_settings = []
# Core reference:
self._core = core
# Maps instance name (str) -> service instance (object)
self._name_instance_map = {}
# Maps service name (str) -> service instance (object)
self._loaded_services = {}
from core.tracing import get_tracer
self.__tracer = get_tracer('AbstractServiceManager')
# Initialize settings infrastructure:
settings_list = [
Setting(
name='instance_list', type=list, required=False,
default_value=[]),
]
settings_list.extend(additional_settings)
SettingsBase.__init__(self, binding=settings_binding,
setting_defs=settings_list)
示例7: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, name, settings_list):
self.__name = name
## Initialize settings:
SettingsBase.__init__(self, binding=('presentations', (name,), 'settings'),
setting_defs=settings_list)
示例8: __init__
# 需要导入模块: from settings.settings_base import SettingsBase [as 别名]
# 或者: from settings.settings_base.SettingsBase import __init__ [as 别名]
def __init__(self, name, settings_list):
self.__name = name
## Initialize settings:
SettingsBase.__init__(self, binding=("services", (name,), "settings"), setting_defs=settings_list)