本文整理汇总了Python中dNG.plugins.hook.Hook.register方法的典型用法代码示例。如果您正苦于以下问题:Python Hook.register方法的具体用法?Python Hook.register怎么用?Python Hook.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dNG.plugins.hook.Hook
的用法示例。
在下文中一共展示了Hook.register方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.user.Profile.delete", delete)
示例2: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.1.00
"""
Hook.register("dNG.pas.Database.applySchema.after", after_apply_schema)
Hook.register("dNG.pas.Database.loadAll", load_all)
示例3: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.http.Server.onStartup", on_startup)
Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
示例4: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.upnp.ControlPoint.onDeviceAdded", on_device_added)
Hook.register("dNG.pas.upnp.ControlPoint.onStartup", on_startup)
示例5: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
#
"""
Register plugin hooks.
:since: v0.1.00
"""
Hook.register("dNG.pas.http.Form.sendEMail", send_email)
示例6: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.upnp.Resource.onRootContainerAdded", on_root_container_added)
Hook.register("dNG.pas.upnp.Resource.onRootContainerDeleted", on_root_container_deleted)
示例7: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.user.Profile.changesConfirmed", changes_confirmed)
Hook.register("dNG.pas.user.Profile.registrationValidated", registration_validated)
示例8: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v1.0.0
"""
Hook.register("dNG.pas.http.Server.onShutdown", on_shutdown)
Hook.register("dNG.pas.http.Server.onStartup", on_startup)
Hook.register("dNG.pas.http.Wsgi.onShutdown", on_shutdown)
Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
示例9: _on_run
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [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)
示例10: _on_run
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [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")))
Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data")))
Settings.read_file("{0}/settings/mp/server.json".format(Settings.get("path_data")))
if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True)
if (args.reload_plugins):
client = BusClient("mp_bus")
client.request("dNG.pas.Plugins.reload")
elif (args.stop):
client = BusClient("mp_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.load("mp")
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("mp_bus")
self._set_time_started(time())
http_server = HttpServer.get_instance()
if (http_server is not None):
Hook.register("dNG.pas.Status.onStartup", http_server.start)
Hook.register("dNG.pas.Status.onShutdown", http_server.stop)
database_tasks = DatabaseTasks.get_instance()
Hook.register("dNG.pas.Status.onStartup", database_tasks.start)
Hook.register("dNG.pas.Status.onShutdown", database_tasks.stop)
memory_tasks = MemoryTasks.get_instance()
Hook.register("dNG.pas.Status.onStartup", memory_tasks.start)
Hook.register("dNG.pas.Status.onShutdown", memory_tasks.stop)
upnp_control_point = ControlPoint.get_instance()
Hook.register("dNG.pas.Status.onStartup", upnp_control_point.start)
Hook.register("dNG.pas.Status.onShutdown", upnp_control_point.stop)
if (self.log_handler is not None): self.log_handler.info("mp starts listening", context = "mp_server")
Hook.call("dNG.pas.Status.onStartup")
self.set_mainloop(self.server.run)
示例11: register_plugin
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def register_plugin():
"""
Register plugin hooks.
:since: v0.2.00
"""
Hook.register("dNG.pas.Status.onShutdown", on_shutdown)
Hook.register("dNG.pas.Status.onStartup", on_startup)
Hook.register("dNG.pas.Tasks.call", call)
Hook.register("dNG.pas.tasks.Persistent.isRegistered", is_persistent_task_registered)
Hook.register("dNG.pas.tasks.Persistent.add", add_persistent_task)
Hook.register("dNG.pas.tasks.Persistent.call", call_persistent_task)
Hook.register("dNG.pas.tasks.Persistent.get", get_persistent_task)
Hook.register("dNG.pas.tasks.Persistent.registerTimeout", register_persistent_timeout_task)
Hook.register("dNG.pas.tasks.Persistent.remove", remove_persistent_task)
Hook.register("dNG.pas.tasks.Persistent.reregisterTimeout", reregister_persistent_timeout_task)
Hook.register("dNG.pas.tasks.Persistent.unregisterTimeout", unregister_persistent_timeout_task)
示例12: __init__
# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import register [as 别名]
def __init__(self, _id):
"""
Constructor __init__(ResourceScanner)
:since: v0.2.00
"""
AbstractLrtHook.__init__(self)
self.id = None
"""
Encapsulating UPnP resource ID
"""
self.refresh_time = None
"""
Refresh time
"""
self.vfs_url = None
"""
UPnP encapsulated VFS URL
"""
self.context_id = "mp.tasks.ResourceScanner"
self.independent_scheduling = True
entry_data = None
with Connection.get_instance():
is_auto_maintained = False
resource = MpEntry.load_encapsulating_entry(_id)
if (isinstance(resource, MpEntry)):
entry_data = resource.get_data_attributes("resource")
is_auto_maintained = resource.is_supported("auto_maintenance")
#
if (is_auto_maintained):
if (self.log_handler is not None): self.log_handler.debug("mp.ResourceScanner ignores auto maintained resource ID '{0}'", _id, context = "mp_server")
elif (entry_data is not None):
self.id = resource.get_resource_id()
self.vfs_url = resource.get_vfs_url()
vfs_scheme = WatcherImplementation.get_scheme_from_vfs_url_if_supported(self.vfs_url)
vfs_watcher = None
if (vfs_scheme is not None):
with ResourceScanner._lock:
if (len(ResourceScanner._watcher_instances) < 1):
Hook.register("dNG.pas.upnp.ControlPoint.onShutdown", ResourceScanner.stop)
#
if (vfs_scheme not in ResourceScanner._watcher_instances):
ResourceScanner._watcher_instances[vfs_scheme] = WatcherImplementation.get_instance(vfs_scheme)
#
vfs_watcher = ResourceScanner._watcher_instances[vfs_scheme]
#
#
is_watched = False
if (vfs_watcher is not None and (not vfs_watcher.is_synchronous())):
is_watched = (vfs_watcher.is_watched(self.vfs_url, ResourceScanner.on_watcher_event)
or vfs_watcher.register(self.vfs_url, ResourceScanner.on_watcher_event)
)
#
if (not is_watched): self.refresh_time = Settings.get("mp_core_entry_scanner_refresh_time", 300)
elif (self.log_handler is not None): self.log_handler.warning("mp.ResourceScanner refused to scan '{0}'", _id, context = "mp_server")