CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 18:17:02 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"b46f5c0cc53004cbde2b5bb78ddd92e1"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=Od%2FYKLVTxmuH2JoF9CZdjpXBev4xVdkGahzpb62X8i6wwrpeSAXcLOnJR1oYb6F8SQiWysoLlWh434NscLg3FoQ%2BxeamSPAcgQiDdXkItabmbA2JoVcDm7GsPHfKoSNVEPBbjBN1Q%2Bg9MMlDa1A5CPsMol8r%2Bl399PTQp%2Ff6fIBF0TY7CR9DyJeOeCi26gJ7nNXU1GFKwx2LZNlOTCs0m441ZshHMgaoaDPIp6B6VVZYdCpdslk3cgwCa6UWYx6cbGR9n0bFSCVwTiV0q%2BfahQ%3D%3D--l11fIXeKOXL0%2FoRj--e83snY62YW1gzjtkOqtnlg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.143680835.1753294621; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 18:17:01 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 18:17:01 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 88AA:351DD4:FA6CFD:1285B05:6881271D
module.plugins.Hook (SourceCode) · pyload/pyload Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 732
module.plugins.Hook (SourceCode)
Jonas edited this page Jun 8, 2016
·
1 revision
# -*- coding: utf-8 -*-
"""
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>.
@author: mkaay
@interface-version: 0.2
"""
from traceback import print_exc
from Plugin import Base
class Expose(object):
""" used for decoration to declare rpc services """
def __new__(cls, f, *args, **kwargs):
hookManager.addRPC(f.__module__, f.func_name, f.func_doc)
return f
def threaded(f):
def run(*args,**kwargs):
hookManager.startThread(f, *args, **kwargs)
return run
[docs]class Hook(Base):
"""
Base class for hook plugins.
"""
__name__ = "Hook"
__version__ = "0.2"
__type__ = "hook"
__threaded__ = []
__config__ = [ ("name", "type", "desc" , "default") ]
__description__ = """interface for hook"""
__author_name__ = ("mkaay", "RaNaN")
__author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org")
#: automatically register event listeners for functions, attribute will be deleted dont use it yourself
event_map = None
# Alternative to event_map
#: List of events the plugin can handle, name the functions exactly like eventname.
event_list = None # dont make duplicate entries in event_map
#: periodic call interval in secondc
interval = 60
[docs] def __init__(self, core, manager):
Base.__init__(self, core)
#: Provide information in dict here, usable by API `getInfo`
self.info = None
#: Callback of periodical job task, used by hookmanager
self.cb = None
#: `HookManager`
self.manager = manager
#register events
if self.event_map:
for event, funcs in self.event_map.iteritems():
if type(funcs) in (list, tuple):
for f in funcs:
self.manager.addEvent(event, getattr(self,f))
else:
self.manager.addEvent(event, getattr(self,funcs))
#delete for various reasons
self.event_map = None
if self.event_list:
for f in self.event_list:
self.manager.addEvent(f, getattr(self,f))
self.event_list = None
self.initPeriodical()
self.setup()
def initPeriodical(self):
if self.interval >=1:
self.cb = self.core.scheduler.addJob(0, self._periodical, threaded=False)
def _periodical(self):
try:
if self.isActivated(): self.periodical()
except Exception, e:
self.core.log.error(_("Error executing hooks: %s") % str(e))
if self.core.debug:
print_exc()
self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False)
def __repr__(self):
return "<Hook %s>" % self.__name__
[docs] def setup(self):
""" more init stuff if needed """
pass
[docs] def unload(self):
""" called when hook was deactivated """
pass
[docs] def isActivated(self):
""" checks if hook is activated"""
return self.config.getPlugin(self.__name__, "activated")
#event methods - overwrite these if needed
def coreReady(self):
pass
def coreExiting(self):
pass
def downloadPreparing(self, pyfile):
pass
def downloadFinished(self, pyfile):
pass
def downloadFailed(self, pyfile):
pass
def packageFinished(self, pypack):
pass
def beforeReconnecting(self, ip):
pass
def afterReconnecting(self, ip):
pass
def periodical(self):
pass
[docs] def newCaptchaTask(self, task):
""" new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """
pass
def captchaCorrect(self, task):
pass
def captchaInvalid(self, task):
pass
This page may no longer be valid. If you find something wrong, please report it.
You can’t perform that action at this time.