本文整理汇总了Python中dNG.data.settings.Settings.get方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get方法的具体用法?Python Settings.get怎么用?Python Settings.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dNG.data.settings.Settings
的用法示例。
在下文中一共展示了Settings.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def __init__(self):
"""
Constructor __init__(GstVideo)
:since: v0.2.00
"""
AbstractVideo.__init__(self)
Gstreamer.__init__(self)
self.playback_control_timeout = 5
"""
Playback control command timeout.
"""
self.thumbnail_position_percentage = 0.05
"""
Position in percent where to generate a thumbnail from.
"""
playback_control_timeout = float(Settings.get("pas_gapi_gstreamer_playback_control_timeout", 0))
if (playback_control_timeout > 0): self.playback_control_timeout = playback_control_timeout
self.supported_features['thumbnail'] = True
thumbnail_position_percentage = Settings.get("pas_gapi_gstreamer_thumbnail_position_percentage", 0)
if (thumbnail_position_percentage > 0
and thumbnail_position_percentage <= 100
): self.thumbnail_position_percentage = (thumbnail_position_percentage / 100)
示例2: __init__
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def __init__(self):
"""
Constructor __init__(Client)
:since: v1.0.0
"""
self._log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False)
"""
The LogHandler is called whenever debug messages should be logged or errors
happened.
"""
self._message = None
"""
e-mail message instance
"""
self.timeout = 0
"""
Request timeout value
"""
Settings.read_file("{0}/settings/pas_email.json".format(Settings.get("path_data")), True)
Settings.read_file("{0}/settings/pas_smtp_client.json".format(Settings.get("path_data")), True)
self.timeout = int(Settings.get("pas_smtp_client_timeout", 30))
示例3: _configure
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _configure(self):
"""
Configures the server
:since: v1.0.0
"""
listener_host = Settings.get("pas_http_twisted_server_host", self.socket_hostname)
self.port = int(Settings.get("pas_http_twisted_server_port", 8080))
self.reactor = reactor
self.reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
server_description = "tcp:{0:d}".format(self.port)
if (listener_host == ""): self.host = Settings.get("pas_http_server_preferred_hostname", self.socket_hostname)
else:
self.host = listener_host
server_description += ":interface={0}".format(self.host)
#
self.thread_pool = ThreadPool()
self.thread_pool.start()
if (self._log_handler is not None): self._log_handler.info("pas.http.core Twisted server starts at '{0}:{1:d}'", listener_host, self.port, context = "pas_http_core")
server = serverFromString(self.reactor, server_description)
server.listen(Site(WSGIResource(reactor, self.thread_pool, HttpWsgi1Request)))
"""
Configure common paths and settings
"""
AbstractServer._configure(self)
示例4: send
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def send(self):
"""
Sends a message.
:since: v1.0.0
"""
if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}.send()- (#echo(__LINE__)#)", self, context = "pas_email")
if (self.message is None): raise IOException("No message defined to be send")
if (not self.message.is_recipient_set): raise ValueException("No recipients defined for e-mail")
if (not self.message.is_subject_set): raise IOException("No subject defined for e-mail")
bcc_list = self.message.bcc
cc_list = self.message.cc
to_list = self.message.to
rcpt_list = to_list
if (len(bcc_list) > 0): rcpt_list = Client._filter_unique_list(rcpt_list, bcc_list)
if (len(cc_list) > 0): rcpt_list = Client._filter_unique_list(rcpt_list, cc_list)
is_auth_possible = False
smtp_user = None
smtp_password = None
if (Settings.is_defined("pas_smtp_client_user") and Settings.is_defined("pas_smtp_client_password")):
is_auth_possible = True
smtp_user = Settings.get("pas_smtp_client_user")
smtp_password = Settings.get("pas_smtp_client_password")
#
smtp_connection = None
try:
smtp_connection = (self._get_lmtp_connection()
if (Settings.is_defined("pas_smtp_client_lmtp_host")
or Settings.is_defined("pas_smtp_client_lmtp_path_name")
)
else self._get_smtp_connection()
)
if (is_auth_possible): smtp_connection.login(smtp_user, smtp_password)
if (not self.message.is_sender_set):
self.message.sender = (Settings.get("pas_email_sender_public")
if (Settings.is_defined("pas_email_sender_public")) else
Settings.get("pas_email_address_public")
)
#
sender = self.message.sender
smtp_connection.sendmail(sender, rcpt_list, self.message.as_string())
self.message = None
finally:
try:
if (smtp_connection is not None): smtp_connection.quit()
except SMTPServerDisconnected: pass
示例5: get_user_agent_settings
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def get_user_agent_settings(user_agent):
"""
Returns the user agent specific client settings dictionary.
:param user_agent: User agent
:return: (dict) User agent specific client settings; None on error
:since: v0.2.00
"""
_return = { }
settings = None
user_agent = Binary.str(user_agent)
if (type(user_agent) is str):
settings = Hook.call("dNG.pas.upnp.Client.getUserAgentSettings", user_agent = user_agent)
if (not isinstance(settings, dict)):
identifier = ClientSettings.get_user_agent_identifiers(user_agent)
settings_file_name = "{0}.json".format(identifier)
settings = JsonFileContent.read(path.join(Settings.get("path_data"),
"upnp",
"user_agents",
settings_file_name
)
)
if (settings is None):
log_line = "pas.upnp.ClientSettings reporting: No client settings found for user agent '{0}' with identifier '{1}'"
if (Settings.get("pas_upnp_log_missing_user_agent", False)): LogLine.warning(log_line, user_agent, identifier, context = "pas_upnp")
else: LogLine.debug(log_line, user_agent, identifier, context = "pas_upnp")
#
#
#
if (settings is not None):
if ("client_file" in settings):
base_settings = JsonFileContent.read(path.join(Settings.get("path_data"),
"upnp",
"user_agents",
InputFilter.filter_file_path(settings['client_file'])
)
)
if (type(base_settings) is dict): _return.update(base_settings)
del(settings['client_file'])
#
_return.update(settings)
#
return _return
示例6: _init_theme_renderer
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _init_theme_renderer(self):
"""
Set up theme framework if renderer has not already been initialized.
:since: v1.0.0
"""
if (self._theme_renderer is None):
if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}._init_theme_renderer()- (#echo(__LINE__)#)", self, context = "pas_http_core")
Settings.read_file("{0}/settings/pas_http_theme.json".format(Settings.get("path_data")))
if (self._theme is None):
theme = AbstractHttpRequest.get_instance().get_parameter("theme")
if (theme is not None): self._theme = theme
#
theme = (Hook.call("dNG.pas.http.Theme.checkCandidates", theme = self._theme)
if (Settings.get("pas_http_theme_plugins_supported", True)) else
None
)
if (theme is not None): theme = re.sub("\\W", "", theme)
self._theme_renderer = NamedLoader.get_instance("dNG.data.xhtml.theme.Renderer")
self._theme_renderer.theme = (self._theme if (theme is None) else theme)
self._theme_active = self._theme_renderer.theme
Settings.set("x_pas_http_theme", self.theme)
self.theme_active_base_path = path.join(Settings.get("path_data"),
"assets",
"themes",
self.theme_active
)
self._theme_renderer.log_handler = self._log_handler
self._theme_renderer.theme = self.theme_active
self._theme_renderer.theme_subtype = self.theme_subtype
if (self._description is not None): self._theme_renderer.description = self._description
if (self._canonical_url is not None): self._theme_renderer.canonical_url = self.canonical_url
for css_file in self.css_files_cache: self.add_css_file(css_file)
self.css_files_cache = [ ]
for js_file in self.js_files_cache: self.add_js_file(js_file)
self.js_files_cache = [ ]
for theme_css_file in self.theme_css_files_cache: self.add_theme_css_file(theme_css_file)
self.theme_css_files_cache = [ ]
for webc_file in self.webc_files_cache: self.add_webc_file(webc_file)
self.webc_files_cache = [ ]
示例7: __init__
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def __init__(self):
"""
Constructor __init__(Module)
:since: v0.2.00
"""
AbstractHttpController.__init__(self)
Settings.read_file("{0}/settings/pas_tasks.json".format(Settings.get("path_data")))
Settings.read_file("{0}/settings/pas_http_tasks.json".format(Settings.get("path_data")))
示例8: _on_run
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _on_run(self, args):
"""
Callback for execution.
:param args: Parsed command line arguments
:since: v0.2.00
"""
# pylint: disable=attribute-defined-outside-init
Settings.read_file("{0}/settings/pas_global.json".format(Settings.get("path_data")))
Settings.read_file("{0}/settings/pas_core.json".format(Settings.get("path_data")), True)
Settings.read_file("{0}/settings/pas_tasks_daemon.json".format(Settings.get("path_data")), True)
if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True)
if (not Settings.is_defined("pas_tasks_daemon_listener_address")): raise IOException("No listener address defined for the TasksDaemon")
if (args.reload_plugins):
client = BusClient("pas_tasks_daemon")
client.request("dNG.pas.Plugins.reload")
elif (args.stop):
client = BusClient("pas_tasks_daemon")
pid = client.request("dNG.pas.Status.getOSPid")
client.request("dNG.pas.Status.stop")
self._wait_for_os_pid(pid)
else:
self.cache_instance = NamedLoader.get_singleton("dNG.data.cache.Content", False)
if (self.cache_instance is not None): Settings.set_cache_instance(self.cache_instance)
self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False)
if (self.log_handler is not None):
Hook.set_log_handler(self.log_handler)
NamedLoader.set_log_handler(self.log_handler)
#
Hook.load("tasks")
Hook.register("dNG.pas.Status.getOSPid", self.get_os_pid)
Hook.register("dNG.pas.Status.getTimeStarted", self.get_time_started)
Hook.register("dNG.pas.Status.getUptime", self.get_uptime)
Hook.register("dNG.pas.Status.stop", self.stop)
self.server = BusServer("pas_tasks_daemon")
self._set_time_started(time())
if (self.log_handler is not None): self.log_handler.info("TasksDaemon starts listening", context = "pas_tasks")
Hook.call("dNG.pas.Status.onStartup")
Hook.call("dNG.pas.tasks.Daemon.onStartup")
self.set_mainloop(self.server.run)
示例9: _on_run
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _on_run(self, args):
"""
Callback for execution.
:param args: Parsed command line arguments
:since: v0.2.00
"""
Settings.read_file("{0}/settings/pas_global.json".format(Settings.get("path_data")))
Settings.read_file("{0}/settings/pas_core.json".format(Settings.get("path_data")), True)
Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data")), True)
if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True)
if (args.reload_plugins):
client = BusClient("pas_http_bus")
client.request("dNG.pas.Plugins.reload")
elif (args.stop):
client = BusClient("pas_http_bus")
pid = client.request("dNG.pas.Status.getOSPid")
client.request("dNG.pas.Status.stop")
self._wait_for_os_pid(pid)
else:
self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False)
if (self.log_handler is not None):
Hook.set_log_handler(self.log_handler)
NamedLoader.set_log_handler(self.log_handler)
#
self.cache_instance = NamedLoader.get_singleton("dNG.data.cache.Content", False)
if (self.cache_instance is not None): Settings.set_cache_instance(self.cache_instance)
Hook.load("http")
Hook.register("dNG.pas.Status.getOSPid", self.get_os_pid)
Hook.register("dNG.pas.Status.getTimeStarted", self.get_time_started)
Hook.register("dNG.pas.Status.getUptime", self.get_uptime)
Hook.register("dNG.pas.Status.stop", self.stop)
self._set_time_started(time())
http_server = _HttpServer.get_instance()
self.server = BusServer("pas_http_bus")
if (http_server is not None):
Hook.register("dNG.pas.Status.onStartup", http_server.start)
Hook.register("dNG.pas.Status.onShutdown", http_server.stop)
if (self.log_handler is not None): self.log_handler.info("pas.http starts listening", context = "pas_http_site")
Hook.call("dNG.pas.Status.onStartup")
self.set_mainloop(self.server.run)
示例10: _get_implementation_class_name
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _get_implementation_class_name():
"""
Returns the media implementation class name based on the configuration set.
:return: (str) Media implementation class name
:since: v0.2.00
"""
Settings.read_file("{0}/settings/pas_media.json".format(Settings.get("path_data")))
_return = Settings.get("pas_media_video_implementation", "")
if (_return == ""): LogLine.warning("Media video implementation class is not configured")
return _return
示例11: __init__
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def __init__(self, _type, control_point = None):
"""
Constructor __init__(ControlPointEvent)
:param _type: Event to be delivered
:param control_point: Control point scheduling delivery
:since: v0.2.00
"""
AbstractEvent.__init__(self, _type)
self.announcement_divider = None
"""
Divider for the announcements interval to set how many announcements will be within the interval
"""
self.announcement_interval = None
"""
Announcement interval
"""
self.configid = None
"""
UPnP configId value (configid.upnp.org)
"""
self.location = None
"""
UPnP HTTP location URL
"""
self.search_target = None
"""
M-SEARCH ST value
"""
self.target_host = None
"""
M-SEARCH response target host
"""
self.target_port = None
"""
M-SEARCH response target port
"""
self.usn = None
"""
UPnP USN
"""
Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data")))
self.announcement_divider = int(Settings.get("pas_upnp_announcement_divider", 3))
self.announcement_interval = int(Settings.get("pas_upnp_announcement_interval", 3600))
self.control_point = control_point
示例12: get_view
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def get_view(self):
"""
Action for "view"
:since: v1.0.0
"""
cid = InputFilter.filter_file_path(self.request.get_parameter("cid", ""))
source_iline = InputFilter.filter_control_chars(self.request.get_parameter("source", "")).strip()
L10n.init("pas_http_core_contentfile")
Settings.read_file("{0}/settings/pas_http_contentfiles.json".format(Settings.get("path_data")))
contentfiles = Settings.get("pas_http_contentfiles_list", { })
if (type(contentfiles) is not dict): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
if (source_iline != ""):
if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.css")
Link.set_store("servicemenu",
Link.TYPE_RELATIVE_URL,
L10n.get("core_back"),
{ "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
icon = "mini-default-back",
priority = 7
)
#
if (cid not in contentfiles
or "title" not in contentfiles[cid]
or "filepath" not in contentfiles[cid]
): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
file_content = FileContent.read(contentfiles[cid]['filepath'])
if (file_content is None): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)
if (path.splitext(contentfiles[cid]['filepath'])[1].lower() == ".ftg"): file_content = FormTags.render(file_content)
content = { "title": contentfiles[cid]['title'],
"content": file_content
}
self.response.init()
self.response.page_title = contentfiles[cid]['title']
self.response.add_oset_content("core.simple_content", content)
示例13: _parse_gst_caps_codec
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _parse_gst_caps_codec(self, caps, codec):
"""
Parses the GStreamer caps codec for a matching mimetype identifier.
:param caps: GStreamer caps dict
:param codec: GStreamer codec name
:return: (str) GStreamer codec / Mimetype identifier
:since: v0.2.00
"""
_return = codec
if (type(caps) is dict and type(codec) is str):
gst_mimetypes = Settings.get("pas_gapi_gstreamer_mimetypes", { })
if (codec in gst_mimetypes):
if (type(gst_mimetypes[codec]) is str): _return = gst_mimetypes[codec]
else:
codec = self._parse_gst_caps_dependencies(caps, gst_mimetypes[codec])
if (codec is not None): _return = codec
#
#
#
return _return
示例14: __init__
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def __init__(self):
"""
Constructor __init__(Multipart)
:since: v1.0.0
"""
Data.__init__(self)
self.parts = None
"""
Parts found in the "multipart/form_data" submission.
"""
self.pending_buffer = None
"""
Currently receiving buffer.
"""
self.pending_buffer_header_size_max = int(Settings.get("pas_http_site_request_body_multipart_pending_buffer_header_size_max", 65536))
"""
Maximum size in bytes for a part header
"""
self.pending_mime_parts = [ ]
"""
MIME parts currently opened.
"""
self.pending_received_data = None
"""
Data received but not yet completely parsed.
"""
self.supported_features['body_parser'] = True
示例15: _enter_context
# 需要导入模块: from dNG.data.settings import Settings [as 别名]
# 或者: from dNG.data.settings.Settings import get [as 别名]
def _enter_context(self):
"""
Enters the connection context.
:since: v1.0.0
"""
if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}._enter_context()- (#echo(__LINE__)#)", self, context = "pas_database")
self._ensure_thread_local()
if (self.local.context_depth < 1):
if (Connection.is_serialized()): Connection._serialized_lock.acquire()
if (self._log_handler is not None
and Settings.get("pas_database_threaded_debug", False)
): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}._enter_context()- reporting: Connection acquired for thread ID {1:d}", self, current_thread().ident, context = "pas_database")
#
try:
self._ensure_thread_local_session()
self.local.context_depth += 1
except Exception:
if (self.local.context_depth < 1
and Connection.is_serialized()
): Connection._serialized_lock.release()
raise