summaryrefslogtreecommitdiffstats
path: root/pyload
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-11 01:04:07 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-11 01:04:07 +0100
commit1b2591b0650a6a0be1ad41022f6019d17192f195 (patch)
treedbd2158b96141ef9354b5cd5edaead28978d65e7 /pyload
parentSupport new key attributes (diff)
downloadpyload-1b2591b0650a6a0be1ad41022f6019d17192f195.tar.xz
Rename some Addon methods
Diffstat (limited to 'pyload')
-rw-r--r--pyload/plugins/Addon.py32
-rw-r--r--pyload/plugins/addon/Checksum.py2
-rw-r--r--pyload/plugins/addon/ClickAndLoad.py2
-rw-r--r--pyload/plugins/addon/DeleteFinished.py4
-rw-r--r--pyload/plugins/addon/DownloadScheduler.py2
-rw-r--r--pyload/plugins/addon/HotFolder.py2
-rw-r--r--pyload/plugins/addon/IRCInterface.py4
-rw-r--r--pyload/plugins/addon/MultiHome.py2
-rw-r--r--pyload/plugins/addon/RestartFailed.py2
-rw-r--r--pyload/plugins/addon/UpdateManager.py4
-rw-r--r--pyload/plugins/addon/WindowsPhoneToastNotify.py2
-rw-r--r--pyload/plugins/addon/XMPPInterface.py2
-rw-r--r--pyload/plugins/hook/BypassCaptcha.py2
-rw-r--r--pyload/plugins/hook/Captcha9kw.py4
-rw-r--r--pyload/plugins/hook/CaptchaBrotherhood.py2
-rw-r--r--pyload/plugins/hook/DeathByCaptcha.py2
-rw-r--r--pyload/plugins/hook/ExpertDecoders.py2
-rw-r--r--pyload/plugins/hook/ImageTyperz.py2
-rw-r--r--pyload/plugins/hook/LinkdecrypterCom.py2
-rw-r--r--pyload/plugins/hook/PremiumTo.py4
-rw-r--r--pyload/plugins/hook/PremiumizeMe.py4
-rw-r--r--pyload/plugins/hook/RPNetBiz.py4
-rw-r--r--pyload/plugins/hook/RehostTo.py4
-rw-r--r--pyload/plugins/hook/XFileSharingPro.py4
-rw-r--r--pyload/plugins/hoster/PremiumizeMe.py2
-rw-r--r--pyload/plugins/internal/MultiHoster.py4
-rw-r--r--pyload/plugins/internal/UpdateManager.py4
-rw-r--r--pyload/utils/__init__.py5
28 files changed, 66 insertions, 45 deletions
diff --git a/pyload/plugins/Addon.py b/pyload/plugins/Addon.py
index ebfb121f9..43743848a 100644
--- a/pyload/plugins/Addon.py
+++ b/pyload/plugins/Addon.py
@@ -3,6 +3,7 @@
from traceback import print_exc
from pyload.plugins.Plugin import Base
+from pyload.utils import has_method
class Expose(object):
@@ -13,10 +14,11 @@ class Expose(object):
return f
-def threaded(f):
+def threaded(fn):
def run(*args,**kwargs):
- addonManager.startThread(f, *args, **kwargs)
+ addonManager.startThread(fn, *args, **kwargs)
+
return run
@@ -33,7 +35,7 @@ class Addon(Base):
__description = """Base addon/hook plugin"""
__license = "GPLv3"
__authors = [("mkaay", "mkaay@mkaay.de"),
- ("RaNaN", "RaNaN@pyload.org")]
+ ("RaNaN", "RaNaN@pyload.org")]
#: automatically register event listeners for functions, attribute will be deleted dont use it yourself
@@ -109,8 +111,12 @@ class Addon(Base):
pass
- def unload(self):
+ def deactivate(self):
""" called when addon was deactivated """
+ if has_method(self.__class__, "unload"):
+ self.unload()
+
+ def unload(self): # Deprecated, use method deactivate() instead
pass
@@ -119,12 +125,22 @@ class Addon(Base):
return self.core.config.getPlugin(self.__name, "activated")
- #event methods - overwrite these if needed
- def coreReady(self):
+ # Event methods - overwrite these if needed
+ def activate(self):
+ """ called when addon was activated """
+ if has_method(self.__class__, "coreReady"):
+ self.coreReady()
+
+ def coreReady(self): # Deprecated, use method activate() instead
pass
- def coreExiting(self):
+ def exit(self):
+ """ called by core.shutdown just before pyLoad exit """
+ if has_method(self.__class__, "coreExiting"):
+ self.coreExiting()
+
+ def coreExiting(self): # Deprecated, use method exit() instead
pass
@@ -156,7 +172,7 @@ class Addon(Base):
pass
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
""" new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """
pass
diff --git a/pyload/plugins/addon/Checksum.py b/pyload/plugins/addon/Checksum.py
index adf542197..1b9941f4b 100644
--- a/pyload/plugins/addon/Checksum.py
+++ b/pyload/plugins/addon/Checksum.py
@@ -63,7 +63,7 @@ class Checksum(Addon):
'default': r'^(?P<hash>[0-9A-Fa-f]+)\s+\*?(?P<name>.+)$'}
- def coreReady(self):
+ def activate(self):
if not self.getConfig("check_checksum"):
self.logInfo(_("Checksum validation is disabled in plugin configuration"))
diff --git a/pyload/plugins/addon/ClickAndLoad.py b/pyload/plugins/addon/ClickAndLoad.py
index 3da2b2220..490837f65 100644
--- a/pyload/plugins/addon/ClickAndLoad.py
+++ b/pyload/plugins/addon/ClickAndLoad.py
@@ -37,7 +37,7 @@ class ClickAndLoad(Addon):
self.interval = 300
- def coreReady(self):
+ def activate(self):
self.initPeriodical()
diff --git a/pyload/plugins/addon/DeleteFinished.py b/pyload/plugins/addon/DeleteFinished.py
index 327b63f4c..5450a8ee2 100644
--- a/pyload/plugins/addon/DeleteFinished.py
+++ b/pyload/plugins/addon/DeleteFinished.py
@@ -38,11 +38,11 @@ class DeleteFinished(Addon):
self.initPeriodical()
- def unload(self):
+ def deactivate(self):
self.removeEvent('packageFinished', self.wakeup)
- def coreReady(self):
+ def activate(self):
self.info = {'sleep': True}
interval = self.getConfig('interval')
self.pluginConfigChanged(self.__name, 'interval', interval)
diff --git a/pyload/plugins/addon/DownloadScheduler.py b/pyload/plugins/addon/DownloadScheduler.py
index 5adbdc33e..95cede509 100644
--- a/pyload/plugins/addon/DownloadScheduler.py
+++ b/pyload/plugins/addon/DownloadScheduler.py
@@ -25,7 +25,7 @@ class DownloadScheduler(Addon):
self.cb = None #: callback to scheduler job; will be by removed AddonManager when addon unloaded
- def coreReady(self):
+ def activate(self):
self.updateSchedule()
diff --git a/pyload/plugins/addon/HotFolder.py b/pyload/plugins/addon/HotFolder.py
index 61e1acf81..297a06c5a 100644
--- a/pyload/plugins/addon/HotFolder.py
+++ b/pyload/plugins/addon/HotFolder.py
@@ -31,7 +31,7 @@ class HotFolder(Addon):
self.interval = 10
- def coreReady(self):
+ def activate(self):
self.initPeriodical()
diff --git a/pyload/plugins/addon/IRCInterface.py b/pyload/plugins/addon/IRCInterface.py
index 3ac018094..e7a905bf7 100644
--- a/pyload/plugins/addon/IRCInterface.py
+++ b/pyload/plugins/addon/IRCInterface.py
@@ -44,7 +44,7 @@ class IRCInterface(Thread, Addon):
self.setDaemon(True)
- def coreReady(self):
+ def activate(self):
self.abort = False
self.more = []
self.new_package = {}
@@ -69,7 +69,7 @@ class IRCInterface(Thread, Addon):
pass
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if self.getConfig("captcha") and task.isTextual():
task.handler.append(self)
task.setWaiting(60)
diff --git a/pyload/plugins/addon/MultiHome.py b/pyload/plugins/addon/MultiHome.py
index d9cc3fd6d..f9c9e1cef 100644
--- a/pyload/plugins/addon/MultiHome.py
+++ b/pyload/plugins/addon/MultiHome.py
@@ -37,7 +37,7 @@ class MultiHome(Addon):
self.interfaces.append(Interface(interface))
- def coreReady(self):
+ def activate(self):
requestFactory = self.core.requestFactory
oldGetRequest = requestFactory.getRequest
diff --git a/pyload/plugins/addon/RestartFailed.py b/pyload/plugins/addon/RestartFailed.py
index caf69869b..ffb305e71 100644
--- a/pyload/plugins/addon/RestartFailed.py
+++ b/pyload/plugins/addon/RestartFailed.py
@@ -41,5 +41,5 @@ class RestartFailed(Addon):
self.interval = 0
- def coreReady(self):
+ def activate(self):
self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval"))
diff --git a/pyload/plugins/addon/UpdateManager.py b/pyload/plugins/addon/UpdateManager.py
index 18b96256b..05197f15d 100644
--- a/pyload/plugins/addon/UpdateManager.py
+++ b/pyload/plugins/addon/UpdateManager.py
@@ -54,13 +54,13 @@ class UpdateManager(Addon):
self.periodical2()
- def coreReady(self):
+ def activate(self):
self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval"))
x = lambda: self.pluginConfigChanged(self.__name, "reloadplugins", self.getConfig("reloadplugins"))
self.core.scheduler.addJob(10, x, threaded=False)
- def unload(self):
+ def deactivate(self):
self.pluginConfigChanged(self.__name, "reloadplugins", False)
diff --git a/pyload/plugins/addon/WindowsPhoneToastNotify.py b/pyload/plugins/addon/WindowsPhoneToastNotify.py
index 6b7c85980..b12ed96d1 100644
--- a/pyload/plugins/addon/WindowsPhoneToastNotify.py
+++ b/pyload/plugins/addon/WindowsPhoneToastNotify.py
@@ -44,7 +44,7 @@ class WindowsPhoneToastNotify(Addon):
self.setStorage("LAST_NOTIFY", time.time())
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if not self.getConfig("pushId") or not self.getConfig("pushUrl"):
return False
diff --git a/pyload/plugins/addon/XMPPInterface.py b/pyload/plugins/addon/XMPPInterface.py
index d634d3f9f..51e904008 100644
--- a/pyload/plugins/addon/XMPPInterface.py
+++ b/pyload/plugins/addon/XMPPInterface.py
@@ -59,7 +59,7 @@ class XMPPInterface(IRCInterface, JabberClient):
]
- def coreReady(self):
+ def activate(self):
self.new_package = {}
self.start()
diff --git a/pyload/plugins/hook/BypassCaptcha.py b/pyload/plugins/hook/BypassCaptcha.py
index e5c455276..9c6d662e0 100644
--- a/pyload/plugins/hook/BypassCaptcha.py
+++ b/pyload/plugins/hook/BypassCaptcha.py
@@ -89,7 +89,7 @@ class BypassCaptcha(Addon):
self.logError(_("Could not send response"), e)
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if "service" in task.data:
return False
diff --git a/pyload/plugins/hook/Captcha9kw.py b/pyload/plugins/hook/Captcha9kw.py
index 5d04a6481..2fc098473 100644
--- a/pyload/plugins/hook/Captcha9kw.py
+++ b/pyload/plugins/hook/Captcha9kw.py
@@ -39,7 +39,7 @@ class Captcha9kw(Addon):
API_URL = "http://www.9kw.eu/index.cgi"
- def coreReady(self):
+ def activate(self):
if self.getConfig("ssl"):
self.API_URL = self.API_URL.replace("http://", "https://")
@@ -164,7 +164,7 @@ class Captcha9kw(Addon):
task.setResult(result)
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if not task.isTextual() and not task.isPositional():
return
diff --git a/pyload/plugins/hook/CaptchaBrotherhood.py b/pyload/plugins/hook/CaptchaBrotherhood.py
index b5e5f34ca..01c5588e3 100644
--- a/pyload/plugins/hook/CaptchaBrotherhood.py
+++ b/pyload/plugins/hook/CaptchaBrotherhood.py
@@ -127,7 +127,7 @@ class CaptchaBrotherhood(Addon):
return res
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if "service" in task.data:
return False
diff --git a/pyload/plugins/hook/DeathByCaptcha.py b/pyload/plugins/hook/DeathByCaptcha.py
index 240f9a5ce..9ab88127a 100644
--- a/pyload/plugins/hook/DeathByCaptcha.py
+++ b/pyload/plugins/hook/DeathByCaptcha.py
@@ -156,7 +156,7 @@ class DeathByCaptcha(Addon):
return ticket, result
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if "service" in task.data:
return False
diff --git a/pyload/plugins/hook/ExpertDecoders.py b/pyload/plugins/hook/ExpertDecoders.py
index d4d125b2a..746dcf246 100644
--- a/pyload/plugins/hook/ExpertDecoders.py
+++ b/pyload/plugins/hook/ExpertDecoders.py
@@ -62,7 +62,7 @@ class ExpertDecoders(Addon):
task.setResult(result)
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if not task.isTextual():
return False
diff --git a/pyload/plugins/hook/ImageTyperz.py b/pyload/plugins/hook/ImageTyperz.py
index 9a9fc0eef..ea914ed23 100644
--- a/pyload/plugins/hook/ImageTyperz.py
+++ b/pyload/plugins/hook/ImageTyperz.py
@@ -103,7 +103,7 @@ class ImageTyperz(Addon):
return ticket, result
- def newCaptchaTask(self, task):
+ def captchaTask(self, task):
if "service" in task.data:
return False
diff --git a/pyload/plugins/hook/LinkdecrypterCom.py b/pyload/plugins/hook/LinkdecrypterCom.py
index 41aa434d4..ad3ace2a6 100644
--- a/pyload/plugins/hook/LinkdecrypterCom.py
+++ b/pyload/plugins/hook/LinkdecrypterCom.py
@@ -17,7 +17,7 @@ class LinkdecrypterCom(Addon):
__authors = [("zoidberg", "zoidberg@mujmail.cz")]
- def coreReady(self):
+ def activate(self):
try:
self.loadPatterns()
except Exception, e:
diff --git a/pyload/plugins/hook/PremiumTo.py b/pyload/plugins/hook/PremiumTo.py
index 31858f8dd..6a4e4a644 100644
--- a/pyload/plugins/hook/PremiumTo.py
+++ b/pyload/plugins/hook/PremiumTo.py
@@ -26,7 +26,7 @@ class PremiumTo(MultiHoster):
return [x.strip() for x in page.replace("\"", "").split(";")]
- def coreReady(self):
+ def activate(self):
self.account = self.core.accountManager.getAccountPlugin("PremiumTo")
user = self.account.selectAccount()[0]
@@ -35,4 +35,4 @@ class PremiumTo(MultiHoster):
self.logError(_("Please add your premium.to account first and restart pyLoad"))
return
- return MultiHoster.coreReady(self)
+ return MultiHoster.activate(self)
diff --git a/pyload/plugins/hook/PremiumizeMe.py b/pyload/plugins/hook/PremiumizeMe.py
index 34f46f6ca..de887999f 100644
--- a/pyload/plugins/hook/PremiumizeMe.py
+++ b/pyload/plugins/hook/PremiumizeMe.py
@@ -42,7 +42,7 @@ class PremiumizeMe(MultiHoster):
return data['result']['hosterlist']
- def coreReady(self):
+ def activate(self):
# Get account plugin and check if there is a valid account available
self.account = self.core.accountManager.getAccountPlugin("PremiumizeMe")
if not self.account.canUse():
@@ -51,4 +51,4 @@ class PremiumizeMe(MultiHoster):
return
# Run the overwriten core ready which actually enables the multihoster hook
- return MultiHoster.coreReady(self)
+ return MultiHoster.activate(self)
diff --git a/pyload/plugins/hook/RPNetBiz.py b/pyload/plugins/hook/RPNetBiz.py
index 25355520b..88e091d37 100644
--- a/pyload/plugins/hook/RPNetBiz.py
+++ b/pyload/plugins/hook/RPNetBiz.py
@@ -40,7 +40,7 @@ class RPNetBiz(MultiHoster):
return hoster_list['hosters']
- def coreReady(self):
+ def activate(self):
# Get account plugin and check if there is a valid account available
self.account = self.core.accountManager.getAccountPlugin("RPNetBiz")
if not self.account.canUse():
@@ -49,4 +49,4 @@ class RPNetBiz(MultiHoster):
return
# Run the overwriten core ready which actually enables the multihoster hook
- return MultiHoster.coreReady(self)
+ return MultiHoster.activate(self)
diff --git a/pyload/plugins/hook/RehostTo.py b/pyload/plugins/hook/RehostTo.py
index ce1dee59c..3da17ea8f 100644
--- a/pyload/plugins/hook/RehostTo.py
+++ b/pyload/plugins/hook/RehostTo.py
@@ -25,7 +25,7 @@ class RehostTo(MultiHoster):
return [x.strip() for x in page.replace("\"", "").split(",")]
- def coreReady(self):
+ def activate(self):
self.account = self.core.accountManager.getAccountPlugin("RehostTo")
user = self.account.selectAccount()[0]
@@ -38,4 +38,4 @@ class RehostTo(MultiHoster):
self.ses = data['ses']
self.long_ses = data['long_ses']
- return MultiHoster.coreReady(self)
+ return MultiHoster.activate(self)
diff --git a/pyload/plugins/hook/XFileSharingPro.py b/pyload/plugins/hook/XFileSharingPro.py
index 698da482f..28cc5f62d 100644
--- a/pyload/plugins/hook/XFileSharingPro.py
+++ b/pyload/plugins/hook/XFileSharingPro.py
@@ -44,7 +44,7 @@ class XFileSharingPro(Addon):
# self.loadPattern()
- def coreReady(self):
+ def activate(self):
self.loadPattern()
@@ -91,6 +91,6 @@ class XFileSharingPro(Addon):
dict['re'] = re.compile(dict['pattern'])
- def unload(self):
+ def deactivate(self):
for type in ("hoster", "crypter"):
self._unload(type, "XFileSharingPro")
diff --git a/pyload/plugins/hoster/PremiumizeMe.py b/pyload/plugins/hoster/PremiumizeMe.py
index f167882b2..af9ae98d9 100644
--- a/pyload/plugins/hoster/PremiumizeMe.py
+++ b/pyload/plugins/hoster/PremiumizeMe.py
@@ -9,7 +9,7 @@ class PremiumizeMe(Hoster):
__type = "hoster"
__version = "0.12"
- __pattern = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady
+ __pattern = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.activate
__description = """Premiumize.me hoster plugin"""
__license = "GPLv3"
diff --git a/pyload/plugins/internal/MultiHoster.py b/pyload/plugins/internal/MultiHoster.py
index 7644d85ff..1b8ecfb03 100644
--- a/pyload/plugins/internal/MultiHoster.py
+++ b/pyload/plugins/internal/MultiHoster.py
@@ -88,7 +88,7 @@ class MultiHoster(Addon):
raise NotImplementedError
- def coreReady(self):
+ def activate(self):
if self.cb:
self.core.scheduler.removeJob(self.cb)
@@ -180,7 +180,7 @@ class MultiHoster(Addon):
del dict['new_name']
- def unload(self):
+ def deactivate(self):
"""Remove override for all hosters. Scheduler job is removed by AddonManager"""
for hoster in self.supported:
self.unloadHoster(hoster)
diff --git a/pyload/plugins/internal/UpdateManager.py b/pyload/plugins/internal/UpdateManager.py
index 87e86f17f..dd5d29d0b 100644
--- a/pyload/plugins/internal/UpdateManager.py
+++ b/pyload/plugins/internal/UpdateManager.py
@@ -50,13 +50,13 @@ class UpdateManager(Addon):
self.periodical2()
- def coreReady(self):
+ def activate(self):
self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval"))
x = lambda: self.pluginConfigChanged(self.__name, "reloadplugins", self.getConfig("reloadplugins"))
self.core.scheduler.addJob(10, x, threaded=False)
- def unload(self):
+ def deactivate(self):
self.pluginConfigChanged(self.__name, "reloadplugins", False)
diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py
index 1c398224f..004274c3e 100644
--- a/pyload/utils/__init__.py
+++ b/pyload/utils/__init__.py
@@ -232,6 +232,11 @@ def fixup(m):
return text # leave as is
+def has_method(obj, name):
+ """ Check if "name" was defined in obj, (false if it was inhereted) """
+ return hasattr(obj, '__dict__') and name in obj.__dict__
+
+
def html_unescape(text):
"""Removes HTML or XML character references and entities from a text string"""
return re.sub("&#?\w+;", fixup, text)