summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-05-07 10:44:36 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-05-07 10:44:36 +0200
commitb61e1467ee19ca96782248c0189424334d5980b7 (patch)
treecb7b7283f725efe9a525e81f535d22cb2a287e54 /module/plugins
parentmerged (diff)
downloadpyload-b61e1467ee19ca96782248c0189424334d5980b7.tar.xz
hooks methods callable via rpc, closed #299
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/Account.py14
-rw-r--r--module/plugins/Hook.py14
-rw-r--r--module/plugins/Plugin.py4
-rw-r--r--module/plugins/hooks/UpdateManager.py9
-rw-r--r--module/plugins/hoster/MegauploadCom.py2
5 files changed, 28 insertions, 15 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index b8de4ddf0..e8ca26749 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -22,7 +22,7 @@ from random import choice
from time import time
from traceback import print_exc
-from module.utils import compare_time
+from module.utils import compare_time, parseFileSize
class WrongPassword(Exception):
pass
@@ -189,17 +189,7 @@ class Account():
return False if self.selectAccount() == (None, None) else True
def parseTraffic(self, string): #returns kbyte
- string = string.strip().lower()
- p = re.compile(r"(\d+[\.,]\d+)(.*)")
- m = p.match(string)
- if m:
- traffic = float(m.group(1).replace(",", "."))
- unit = m.group(2).strip()
- if unit == "gb" or unit == "gig" or unit == "gbyte" or unit == "gigabyte":
- traffic *= 1024*1024
- elif unit == "mb" or unit == "megabyte" or unit == "mbyte" or unit == "mib":
- traffic *= 1024
- return traffic
+ return parseFileSize(string) / 1024
def wrongPassword(self):
raise WrongPassword
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index 4af6a0ed4..c9d9c8778 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -20,6 +20,20 @@
from thread import start_new_thread
+
+class Expose(object):
+ """ used for decoration to declare rpc services """
+ def __init__(self, *args, **kwargs):
+ self._f = args[0]
+ hookManager.addRPC(self._f.__module__, self._f.func_name, self._f.func_doc)
+
+ def __get__(self, obj, klass):
+ self._obj = obj
+ return self
+
+ def __call__(self, *args, **kwargs):
+ return self._f(self._obj, *args, **kwargs)
+
def threaded(f):
def run(*args,**kwargs):
return start_new_thread(f, args, kwargs)
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 4d8766250..cef839861 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -437,6 +437,10 @@ class Plugin(object):
self.lastCheck = m
return name
+
+ def getPassword(self):
+ return self.pyfile.package().password
+
def clean(self):
""" clean everything and remove references """
if hasattr(self, "pyfile"):
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index df81ebbe7..026cd0c9f 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -20,7 +20,7 @@
from os.path import join
from module.network.RequestFactory import getURL
-from module.plugins.Hook import threaded, Hook
+from module.plugins.Hook import threaded, Expose, Hook
class UpdateManager(Hook):
__name__ = "UpdateManager"
@@ -48,8 +48,13 @@ class UpdateManager(Hook):
else:
self.log.info(_("No plugin updates available"))
+ @Expose
+ def recheckForUpdates(self):
+ """recheck if updates are available"""
+ self.periodical()
+
def checkForUpdate(self):
- """ checks if an update is available"""
+ """checks if an update is available"""
try:
version_check = getURL("http://get.pyload.org/check/%s/" % self.core.server_methods.get_server_version())
diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py
index f73ecf308..5c893f5df 100644
--- a/module/plugins/hoster/MegauploadCom.py
+++ b/module/plugins/hoster/MegauploadCom.py
@@ -130,7 +130,7 @@ class MegauploadCom(Hoster):
self.fail(_("You need premium to download files larger than 1 GB"))
if r'Please enter the password below' in self.html[0]:
- pw = self.pyfile.package().password
+ pw = self.getPassword()
if not pw:
self.fail(_("The file is password protected, enter a password and restart."))