当前位置: 首页>>代码示例>>Python>>正文


Python Hook.register方法代码示例

本文整理汇总了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)
开发者ID:dNG-git,项目名称:pas_user_profile,代码行数:10,代码来源:pas_user_profile.py

示例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)
开发者ID:dNG-git,项目名称:pas_file_center,代码行数:11,代码来源:pas_file_center.py

示例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)
开发者ID:dNG-git,项目名称:pas_http_tasks,代码行数:11,代码来源:pas_http_tasks.py

示例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)
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:11,代码来源:pas_upnp.py

示例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)
开发者ID:dNG-git,项目名称:pas_http_file_form,代码行数:11,代码来源:pas_http_file_form.py

示例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)
开发者ID:dNG-git,项目名称:mp_core,代码行数:11,代码来源:mp_core.py

示例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)
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:11,代码来源:pas_http_user.py

示例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)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:13,代码来源:pas_http_core.py

示例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)
开发者ID:dNG-git,项目名称:pas_tasks_loader,代码行数:56,代码来源:tasks_daemon.py

示例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)
开发者ID:dNG-git,项目名称:mp_loader,代码行数:72,代码来源:mp.py

示例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)
开发者ID:dNG-git,项目名称:pas_tasks,代码行数:20,代码来源:pas_tasks.py

示例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")
开发者ID:dNG-git,项目名称:mp_core,代码行数:71,代码来源:resource_scanner.py


注:本文中的dNG.plugins.hook.Hook.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。