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


Python Hook.call方法代码示例

本文整理汇总了Python中dNG.plugins.hook.Hook.call方法的典型用法代码示例。如果您正苦于以下问题:Python Hook.call方法的具体用法?Python Hook.call怎么用?Python Hook.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dNG.plugins.hook.Hook的用法示例。


在下文中一共展示了Hook.call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _init_content

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def _init_content(self):
        """
Initializes the content of a container.

:return: (bool) True if successful
:since:  v0.2.00
        """

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}._init_content()- (#echo(__LINE__)#)", self, context = "pas_upnp")
        _return = False

        if (self.content is None):
            with self._lock:
                # Thread safety
                Resource._init_content(self)
                _type = self.get_type()

                if (_type is not None and
                    _type & Abstract.TYPE_CDS_ITEM == Abstract.TYPE_CDS_ITEM
                   ):
                    Hook.call("dNG.pas.upnp.Resource.getItemResourceClientContent", item = self)
                    if (len(self.content) == 0): Hook.call("dNG.pas.upnp.Resource.getItemResourceContent", item = self)

                    _return = True
                #
            #
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:31,代码来源:abstract.py

示例2: execute_unsubscribe

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def execute_unsubscribe(self):
        """
Action for "request"

:since: v0.2.00
        """

        self.response.init()
        self.response.set_header("Date", RfcBasics.get_rfc5322_datetime(time()))

        if (not isinstance(self.request, HttpUpnpRequest)): raise UpnpException("pas_http_core_400")
        upnp_service = self.request.get_upnp_service()
        if (not isinstance(upnp_service, AbstractService)): raise UpnpException("pas_http_core_400", 401)

        Hook.call("dNG.pas.http.l10n.upnp.Events.init")

        gena_sid = self.request.get_header("SID")
        upnp_service.set_client_settings(self.get_client_settings())

        if (gena_sid is None): raise UpnpException("pas_http_core_400", 400)

        gena = Gena.get_instance()
        usn = upnp_service.get_usn()

        if (not gena.deregister(usn, gena_sid)): raise UpnpException("pas_http_core_404", 412)

        self.response.set_raw_data("")
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:29,代码来源:events.py

示例3: run

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def run(self):
        """
Worker loop

:since: v0.2.00
        """

        # pylint: disable=broad-except

        mainloop = None

        with GlibThread._lock:
            if (self.mainloop is None):
                mainloop = GLib.MainLoop()
                self.mainloop = mainloop
            #
        #

        if (mainloop is not None):
            if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.run()- (#echo(__LINE__)#)", self, context = "pas_gapi_core")

            try: mainloop.run()
            except Exception as handled_exception: LogLine.error(handled_exception, context = "pas_gapi_core")
            except KeyboardInterrupt: Hook.call("dNG.pas.Status.stop")
            finally: self.stop()
开发者ID:dNG-git,项目名称:pas_gapi_core,代码行数:27,代码来源:glib_thread.py

示例4: delete

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
def delete(params, last_return = None):
    """
Called for "dNG.pas.user.Profile.delete"

:param params: Parameter specified
:param last_return: The return value from the last hook called.

:return: (mixed) Return value
:since:  v0.2.00
    """

    # pylint: disable=star-args

    if ("username" not in params): raise ValueException("Missing required argument")
    else:
        user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")

        try:
            user_profile = user_profile_class.load_username(params['username'])

            Hook.call("dNG.pas.user.Profile.onDelete", user_profile_id = user_profile.get_id())
            user_profile.delete()
        except NothingMatchedException: pass
    #

    return last_return
开发者ID:dNG-git,项目名称:pas_user_profile,代码行数:28,代码来源:pas_user_profile.py

示例5: _init_content

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def _init_content(self):
        """
Initializes the content of a container.

:return: (bool) True if successful
:since:  v0.2.00
        """

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}._init_content()- (#echo(__LINE__)#)", self, context = "pas_upnp")
        _return = False

        if (self.content is None):
            with self._lock:
                # Thread safety
                _return = Abstract._init_content(self)

                if (not _return):
                    if (self.resource_id == "0"):
                        Hook.call("dNG.pas.upnp.Resource.getRootResourceClientContent", container = self)
                        if (len(self.content) == 0): Hook.call("dNG.pas.upnp.Resource.getRootResourceContent", container = self)

                        _return = True
                    #
                #
            #
        #

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:30,代码来源:root_container.py

示例6: init_host

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def init_host(self, device, service_id, configid = None):
        """
Initializes a host service.

:param device: Host device this UPnP service is added to
:param service_id: Unique UPnP service ID
:param configid: UPnP configId for the host device

:return: (bool) Returns true if initialization was successful.
:since:  v0.2.00
        """

        self.configid = configid
        self.host_service = True
        self.service_id = service_id
        self.udn = device.get_udn()

        self.url_base = "{0}{1}/".format(device.get_url_base(), Link.encode_query_value(service_id))
        self.url_control = "{0}control".format(self.url_base)
        self.url_event_control = "{0}eventsub".format(self.url_base)
        self.url_scpd = "{0}xml".format(self.url_base)

        self._init_host_actions(device)
        self._init_host_variables(device)

        Hook.call("dNG.pas.upnp.Service.initHost", device = device, service = self)
        Hook.register_weakref("dNG.pas.upnp.Gena.onRegistered", self._on_gena_registration)

        return ((len(self.actions) + len(self.variables)) > 0)
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:31,代码来源:abstract_service.py

示例7: _on_run

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [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

示例8: _on_shutdown

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def _on_shutdown(self):
        """
Callback for shutdown.

:since: v0.2.00
        """

        Hook.call("dNG.pas.Status.onShutdown")

        if (self.cache_instance is not None): self.cache_instance.disable()
        Hook.free()
开发者ID:dNG-git,项目名称:mp_loader,代码行数:13,代码来源:mp.py

示例9: _on_run

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [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)
开发者ID:dNG-git,项目名称:pas_http_loader,代码行数:55,代码来源:http_server.py

示例10: execute_subscribe

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def execute_subscribe(self):
        """
Action for "request"

:since: v0.2.00
        """

        self.response.init()
        self.response.set_header("Date", RfcBasics.get_rfc5322_datetime(time()))

        if (not isinstance(self.request, HttpUpnpRequest)): raise UpnpException("pas_http_core_400")
        upnp_service = self.request.get_upnp_service()
        if (not isinstance(upnp_service, AbstractService)): raise UpnpException("pas_http_core_400", 401)

        Hook.call("dNG.pas.http.l10n.upnp.Events.init")

        callback_value = self.request.get_header("Callback")
        client_settings = self.get_client_settings()
        gena_sid = self.request.get_header("SID")

        upnp_service.set_client_settings(client_settings)

        if ((callback_value is None or self.request.get_header("NT") != "upnp:event")
            and gena_sid is None
           ): raise UpnpException("pas_http_core_400", 400)

        gena = Gena.get_instance()
        timeout = self.request.get_header("Timeout")

        re_result = (None if (timeout is None) else re.match("^Second-(\\d+)$", timeout))

        if (re_result is None): timeout = int(client_settings.get("upnp_subscription_timeout", 1800))
        else: timeout = int(re_result.group(1))

        usn = upnp_service.get_usn()

        if (gena_sid is None):
            gena_variables = self.request.get_header("StateVar")

            gena_sid = gena.register(usn, callback_value, timeout, variables = gena_variables)
            if (gena_sid is None): raise UpnpException("pas_http_core_404", 412)

            self.response.set_header("SID", gena_sid)
            self.response.set_header("Timeout", "Second-{0:d}".format(timeout))
            if (gena_variables != ""): self.response.set_header("Accepted-StateVar", gena_variables)
            self.response.set_raw_data("")
        else:
            result = gena.reregister(usn, gena_sid, timeout)
            if (result == False): raise UpnpException("pas_http_core_404", 412)

            self.response.set_header("SID", gena_sid)
            self.response.set_header("Timeout", "Second-{0:d}".format(timeout))
            self.response.set_raw_data("")
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:55,代码来源:events.py

示例11: stop

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def stop(self, params = None, last_return = None):
        """
Stop the server

:param params: Parameter specified
:param last_return: The return value from the last hook called.

:return: (mixed) Return value
:since:  v1.0.0
        """

        Hook.call("dNG.pas.http.Server.onShutdown", server = self)
        return last_return
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:15,代码来源:abstract_server.py

示例12: init_cds_id

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def init_cds_id(self, _id, client_user_agent = None, deleted = False):
        """
Initialize a UPnP resource by CDS ID.

:param _id: UPnP CDS ID
:param client_user_agent: Client user agent
:param update_id: UPnP UpdateID value
:param deleted: True to include deleted resources

:return: (bool) Returns true if initialization was successful.
:since:  v0.2.00
        """

        if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.init_cds_id({1})- (#echo(__LINE__)#)", self, _id, context = "pas_upnp")
        _return = Abstract.init_cds_id(self, _id, client_user_agent, deleted)

        if (_id == "0"):
            self.name = L10n.get("pas_upnp_container_root")
            self.type = RootContainer.TYPE_CDS_CONTAINER

            search_segments = Hook.call("dNG.pas.upnp.Resource.getSearchSegments", id = _id)
            self.searchable = (type(search_segments) is list and len(search_segments) > 0)
        else: _return = True

        return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:27,代码来源:root_container.py

示例13: handle_upnp_stream_request

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
def handle_upnp_stream_request(request, virtual_config):
    """
Handles a UPnP stream related HTTP request.

:param request: Originating request instance
:param virtual_config: Virtual path configuration

:return: (object) Request object if valid
:since:  v0.2.00
    """

    if (not isinstance(request, AbstractHttpRequest)): raise TranslatableException("pas_http_core_400", 400)

    user_agent = request.get_header("User-Agent")
    stream_path = request.get_dsd("upnp_path")

    client_settings = ClientSettings(user_agent)

    if (client_settings.get("upnp_stream_path_use_filter", False)):
        stream_path_filtered = Hook.call("dNG.pas.http.HttpUpnpRequest.filterStreamPath", path = stream_path, user_agent = user_agent)
        if (stream_path_filtered is not None): stream_path = stream_path_filtered
    #

    if (stream_path is not None): stream_path = unquote(stream_path)

    _return = PredefinedHttpRequest()
    _return.set_module("upnp")
    _return.set_service("stream")
    _return.set_action("resource")
    _return.set_dsd("urid", stream_path)

    return _return
开发者ID:dNG-git,项目名称:pas_upnp,代码行数:34,代码来源:pas_upnp.py

示例14: init_cds_id

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
    def init_cds_id(self, _id, client_user_agent = None, deleted = False):
        """
Initialize a UPnP resource by CDS ID.

:param _id: UPnP CDS ID
:param client_user_agent: Client user agent
:param deleted: True to include deleted resources

:return: (bool) Returns true if initialization was successful.
:since:  v0.2.00
        """

        Abstract.init_cds_id(self, _id, client_user_agent, deleted)
        _return = (self.resource_id is not None)

        if (_return):
            url_elements = urlsplit(self.resource_id)
            url_path_elements = url_elements.path[1:].split("/", 1)

            hook_id = url_path_elements[0]

            hook_params = (dict(parse_qsl(unquote(url_path_elements[1]), keep_blank_values = True))
                           if (len(url_path_elements) == 2) else
                           { }
                          )

            resource_data = Hook.call("mp.upnp.HookResource.getResourceData", id = hook_id, **hook_params)

            if (self.init(resource_data)):
                self.hook_id = hook_id
                self.hook_params = hook_params
            else: _return = False
        #

        return _return
开发者ID:dNG-git,项目名称:mp_core,代码行数:37,代码来源:hook_resource.py

示例15: call_task

# 需要导入模块: from dNG.plugins.hook import Hook [as 别名]
# 或者: from dNG.plugins.hook.Hook import call [as 别名]
def call_task(request, virtual_config):
    """
Called for requests with the path prefix "/tasks/".

:param request: Originating request instance
:param virtual_config: Virtual path configuration

:return: (object) Request object if valid
:since:  v0.2.00
    """

    _return = None

    tid = request.get_dsd("tid")

    with ExceptionLogTrap("pas_http_site"):
        _return = (None
                   if (tid is None) else
                   Hook.call("dNG.pas.Tasks.call", client = request.get_client_host(), tid = tid)
                  )
    #

    if (_return is None):
        LogLine.warning("pas.Tasks.call refused TID '{0}'", tid, context = "pas_http_site")
        _return = handle_task_result_none()
    #

    return _return
开发者ID:dNG-git,项目名称:pas_http_tasks,代码行数:30,代码来源:pas_http_tasks.py


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