本文整理汇总了Python中dNG.plugins.hook.Hook类的典型用法代码示例。如果您正苦于以下问题:Python Hook类的具体用法?Python Hook怎么用?Python Hook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute_unsubscribe
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("")
示例2: _init_content
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
示例3: run
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()
示例4: stop
def stop(self, params = None, last_return = None):
"""
Stop the running GLib based main loop.
:param params: Parameter specified
:param last_return: The return value from the last hook called.
:since: v0.2.00
"""
if (self.mainloop is not None):
# Thread safety
with GlibThread._lock:
if (self.mainloop is not None):
if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.stop()- (#echo(__LINE__)#)", self, context = "pas_gapi_core")
if (self.mainloop.is_running()):
with ExceptionLogTrap("pas_gapi_core"): self.mainloop.quit()
#
self.mainloop = None
Hook.unregister("dNG.pas.Status.onShutdown", self.stop)
#
#
#
return last_return
示例5: _init_content
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
示例6: delete
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
示例7: init_host
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)
示例8: unregister_plugin
def unregister_plugin():
"""
Unregister plugin hooks.
:since: v0.2.00
"""
Hook.unregister("dNG.pas.user.Profile.delete", delete)
示例9: _on_shutdown
def _on_shutdown(self):
"""
Callback for shutdown.
:since: v1.0.0
"""
Hook.free()
示例10: register_plugin
def register_plugin():
"""
Register plugin hooks.
:since: v1.0.0
"""
Hook.register("dNG.pas.Database.applySchema.after", after_apply_schema)
Hook.register("dNG.pas.Database.loadAll", load_all)
示例11: unregister_plugin
def unregister_plugin():
"""
Unregister plugin hooks.
:since: v0.2.00
"""
Hook.unregister("dNG.pas.upnp.Resource.onRootContainerAdded", on_root_container_added)
Hook.unregister("dNG.pas.upnp.Resource.onRootContainerDeleted", on_root_container_deleted)
示例12: unregister_plugin
def unregister_plugin():
"""
Unregister plugin hooks.
:since: v0.2.00
"""
Hook.unregister("dNG.pas.user.Profile.changesConfirmed", changes_confirmed)
Hook.unregister("dNG.pas.user.Profile.registrationValidated", registration_validated)
示例13: register_plugin
def register_plugin():
#
"""
Register plugin hooks.
:since: v0.1.00
"""
Hook.register("dNG.pas.http.Form.sendEMail", send_email)
示例14: unregister_plugin
def unregister_plugin():
"""
Unregister plugin hooks.
:since: v0.2.00
"""
Hook.unregister("dNG.pas.upnp.ControlPoint.onDeviceAdded", on_device_added)
Hook.unregister("dNG.pas.upnp.ControlPoint.onStartup", on_startup)
示例15: unregister_plugin
def unregister_plugin():
"""
Unregister plugin hooks.
:since: v0.1.00
"""
Hook.unregister("dNG.pas.Database.applySchema.after", after_apply_schema)
Hook.unregister("dNG.pas.Database.loadAll", load_all)