summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/PyFile.py6
-rw-r--r--module/database/FileDatabase.py4
-rw-r--r--module/gui/Collector.py21
-rw-r--r--module/network/RequestFactory.py2
-rw-r--r--module/plugins/Plugin.py4
-rw-r--r--module/plugins/PluginManager.py187
-rw-r--r--module/plugins/hooks/MergeFiles.py2
-rw-r--r--module/plugins/hooks/UpdateManager.py10
-rw-r--r--module/plugins/hoster/BitshareCom.py7
-rw-r--r--module/remote/thriftbackend/pyload.thrift4
-rw-r--r--module/remote/thriftbackend/thriftgen/pyload/ttypes.py12
11 files changed, 131 insertions, 128 deletions
diff --git a/module/PyFile.py b/module/PyFile.py
index 1a574d51d..6d887bbb3 100644
--- a/module/PyFile.py
+++ b/module/PyFile.py
@@ -28,9 +28,9 @@ statusMap = {
"offline": 1,
"online": 2,
"queued": 3,
- "checking": 4,
+ "skipped": 4,
"waiting": 5,
- "reconnected": 6,
+ "temp. offline": 6,
"starting": 7,
"failed": 8,
"aborted": 9,
@@ -38,7 +38,7 @@ statusMap = {
"custom": 11,
"downloading": 12,
"processing": 13,
- "unknown": 14
+ "unknown": 14,
}
def formatSize(size):
diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py
index 5c976eda4..37cfcb7b8 100644
--- a/module/database/FileDatabase.py
+++ b/module/database/FileDatabase.py
@@ -38,7 +38,7 @@ try:
except:
import sqlite3
-########################################################################
+
class FileHandler:
"""Handles all request made to obtain information,
modify status or other request for links or packages"""
@@ -50,7 +50,7 @@ class FileHandler:
self.core = core
# translations
- self.statusMsg = [_("finished"), _("offline"), _("online"), _("queued"), _("checking"), _("waiting"), _("reconnected"), _("starting"), _("failed"), _("aborted"), _("decrypting"), _("custom"), _("downloading"), _("processing"), _("unknown")]
+ self.statusMsg = [_("finished"), _("offline"), _("online"), _("queued"), _("skipped"), _("waiting"), _("temp. offline"), _("starting"), _("failed"), _("aborted"), _("decrypting"), _("custom"), _("downloading"), _("processing"), _("unknown")]
self.cache = {} #holds instances for files
self.packageCache = {} # same for packages
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index cae429de3..caeff4460 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -20,23 +20,8 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from module.remote.thriftbackend.thriftgen.pyload.ttypes import *
+from module.PyFile import statusMap
-statusMap = {
- "finished": 0,
- "offline": 1,
- "online": 2,
- "queued": 3,
- "checking": 4,
- "waiting": 5,
- "reconnected": 6,
- "starting": 7,
- "failed": 8,
- "aborted": 9,
- "decrypting": 10,
- "custom": 11,
- "downloading": 12,
- "processing": 13
-}
statusMapReverse = dict((v,k) for k, v in statusMap.iteritems())
translatedStatusMap = {} # -> CollectorModel.__init__
@@ -73,9 +58,9 @@ class CollectorModel(QAbstractItemModel):
"offline": _("offline"),
"online": _("online"),
"queued": _("queued"),
- "checking": _("checking"),
+ "skipped": _("skipped"),
"waiting": _("waiting"),
- "reconnected": _("reconnected"),
+ "temp. offline": _("temp. offline"),
"starting": _("starting"),
"failed": _("failed"),
"aborted": _("aborted"),
diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py
index e91b9ea41..27854e95e 100644
--- a/module/network/RequestFactory.py
+++ b/module/network/RequestFactory.py
@@ -56,7 +56,7 @@ class RequestFactory():
def getHTTPRequest(self):
""" returns a http request, dont forget to close it ! """
- return HTTPRequest(None, self.iface(), self.getProxies())
+ return HTTPRequest(CookieJar(None), self.iface(), self.getProxies())
def getURL(self, url, get={}, post={}, multipart=False):
h = HTTPRequest(None, self.iface(), self.getProxies())
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index a8009f6d4..32e5e8d4d 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -222,6 +222,10 @@ class Plugin(object):
""" fail and indicate file is offline """
raise Fail("offline")
+ def tempOffline(self):
+ """ fail and indicates file ist temporary offline, the core may take consequences """
+ raise Fail("temp. offline")
+
def retry(self):
""" begin again from the beginning """
raise Retry
diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py
index 0848d520e..acfabde21 100644
--- a/module/plugins/PluginManager.py
+++ b/module/plugins/PluginManager.py
@@ -38,10 +38,10 @@ NO_AUTOLOAD = ("XMPPInterface", "MultiHome", "Ev0InFetcher")
class PluginManager():
def __init__(self, core):
self.core = core
-
+
#self.config = self.core.config
self.log = core.log
-
+
self.crypterPlugins = {}
self.containerPlugins = {}
self.hosterPlugins = {}
@@ -49,34 +49,41 @@ class PluginManager():
self.accountPlugins = {}
self.hookPlugins = {}
+ self.plugins = {"crypter": self.crypterPlugins,
+ "container": self.containerPlugins,
+ "hoster": self.hosterPlugins,
+ "captcha": self.captchaPlugins,
+ "accounts": self.accountPlugins,
+ "hooks": self.hookPlugins}
+
self.createIndex()
-
+
def createIndex(self):
"""create information for all plugins available"""
-
+
sys.path.append(abspath(""))
-
+
if not exists("userplugins"):
makedirs("userplugins")
if not exists(join("userplugins", "__init__.py")):
f = open(join("userplugins", "__init__.py"), "wb")
f.close()
-
+
self.rePattern = re.compile(r'__pattern__.*=.*r("|\')([^"\']+)')
self.reVersion = re.compile(r'__version__.*=.*("|\')([0-9.]+)')
self.reConfig = re.compile(r'__config__.*=.*\[([^\]]+)', re.MULTILINE)
-
+
self.crypterPlugins = self.parse(_("Crypter"), "crypter", pattern=True)
self.containerPlugins = self.parse(_("Container"), "container", pattern=True)
- self.hosterPlugins = self.parse(_("Hoster") ,"hoster", pattern=True)
-
+ self.hosterPlugins = self.parse(_("Hoster"), "hoster", pattern=True)
+
self.captchaPlugins = self.parse(_("Captcha"), "captcha")
self.accountPlugins = self.parse(_("Account"), "accounts", create=True)
self.hookPlugins = self.parse(_("Hook"), "hooks")
self.log.debug("created index of plugins")
-
+
def parse(self, typ, folder, create=False, pattern=False, home={}):
"""
returns dict with information
@@ -98,40 +105,38 @@ class PluginManager():
else:
pfolder = join(pypath, "module", "plugins", folder)
-
+
for f in listdir(pfolder):
- if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or f.endswith("_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"):
+ if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or f.endswith(
+ "_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"):
data = open(join(pfolder, f))
content = data.read()
data.close()
-
+
if f.endswith("_25.pyc") and not version_info[0:2] == (2, 5):
continue
elif f.endswith("_26.pyc") and not version_info[0:2] == (2, 6):
continue
elif f.endswith("_27.pyc") and not version_info[0:2] == (2, 7):
continue
-
+
name = f[:-3]
- if name[-1] == "." : name = name[:-4]
-
-
+ if name[-1] == ".": name = name[:-4]
+
version = self.reVersion.findall(content)
if version:
version = float(version[0][1])
else:
version = 0
-
+
if home and home.has_key(name):
if home[name]["v"] >= version:
continue
-
-
+
plugins[name] = {}
plugins[name]["v"] = version
-
-
- module = f.replace(".pyc","").replace(".py","")
+
+ module = f.replace(".pyc", "").replace(".py", "")
if home:
if name in IGNORE:
del plugins[name]
@@ -139,140 +144,138 @@ class PluginManager():
path = "userplugins.%s.%s" % (folder, module)
else:
path = "module.plugins.%s.%s" % (folder, module)
-
- plugins[name]["name"] = module
+
+ plugins[name]["name"] = module
plugins[name]["path"] = path
-
-
+
if pattern:
pattern = self.rePattern.findall(content)
-
+
if pattern:
pattern = pattern[0][1]
else:
pattern = "^unmachtable$"
-
+
plugins[name]["pattern"] = pattern
-
+
try:
plugins[name]["re"] = re.compile(pattern)
except:
self.log.error(_("%s has a invalid pattern.") % name)
-
config = self.reConfig.findall(content)
-
+
if config:
config = literal_eval(config[0].strip().replace("\n", "").replace("\r", ""))
if type(config[0]) == tuple:
config = [list(x) for x in config]
else:
config = [list(config)]
-
+
if folder == "hooks":
- config.append( ["load", "bool", "Load on startup", True if name not in NO_AUTOLOAD else False] )
-
+ config.append(["load", "bool", "Load on startup", True if name not in NO_AUTOLOAD else False])
+
for item in config:
- self.core.config.addPluginConfig([name]+item)
-
+ self.core.config.addPluginConfig([name] + item)
+
if not home:
temp = self.parse(typ, folder, create, pattern, plugins)
plugins.update(temp)
-
+
return plugins
-
- #----------------------------------------------------------------------
+
+
def parseUrls(self, urls):
"""parse plugins for given list of urls"""
-
+
last = None
res = [] # tupels of (url, plugin)
-
+
for url in urls:
if type(url) not in (str, unicode, buffer): continue
found = False
-
+
if last and last[1]["re"].match(url):
res.append((url, last[0]))
continue
-
- for name, value in chain(self.crypterPlugins.iteritems(), self.hosterPlugins.iteritems(), self.containerPlugins.iteritems() ):
+
+ for name, value in chain(self.crypterPlugins.iteritems(), self.hosterPlugins.iteritems(),
+ self.containerPlugins.iteritems()):
if value["re"].match(url):
res.append((url, name))
last = (name, value)
found = True
break
-
+
if not found:
- res.append((url, "BasePlugin"))
-
+ res.append((url, "BasePlugin"))
+
return res
-
- #----------------------------------------------------------------------
+
+
def getPlugin(self, name):
"""return plugin module from hoster|decrypter|container"""
plugin = None
-
+
if self.containerPlugins.has_key(name):
plugin = self.containerPlugins[name]
if self.crypterPlugins.has_key(name):
plugin = self.crypterPlugins[name]
if self.hosterPlugins.has_key(name):
plugin = self.hosterPlugins[name]
-
-
+
if plugin.has_key("module"):
return plugin["module"]
-
- plugin["module"] = __import__(plugin["path"], globals(), locals(), [plugin["name"]] , -1)
-
+
+ plugin["module"] = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1)
+
return plugin["module"]
-
-
- #----------------------------------------------------------------------
+
+
def getCaptchaPlugin(self, name):
"""return captcha modul if existent"""
if self.captchaPlugins.has_key(name):
plugin = self.captchaPlugins[name]
if plugin.has_key("class"):
return plugin["class"]
-
- module = __import__(plugin["path"], globals(), locals(), [plugin["name"]] , -1)
+
+ module = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1)
plugin["class"] = getattr(module, name)
-
+
return plugin["class"]
-
+
return None
- #----------------------------------------------------------------------
+
+
def getAccountPlugin(self, name):
"""return account class if existent"""
if self.accountPlugins.has_key(name):
plugin = self.accountPlugins[name]
if plugin.has_key("class"):
return plugin["class"]
-
- module = __import__(plugin["path"], globals(), locals(), [plugin["name"]] , -1)
+
+ module = __import__(plugin["path"], globals(), locals(), [plugin["name"]], -1)
plugin["class"] = getattr(module, plugin["name"])
-
+
return plugin["class"]
-
+
return None
-
- #----------------------------------------------------------------------
+
+
def getAccountPlugins(self):
"""return list of account plugin names"""
res = []
-
+
for name in self.accountPlugins.keys():
res.append(name)
-
+
return res
- #----------------------------------------------------------------------
+
def getHookPlugins(self):
"""return list of hook classes"""
-
+
classes = []
-
+
for name, value in self.hookPlugins.iteritems():
if value.has_key("class"):
classes.append(value["class"])
@@ -284,12 +287,12 @@ class PluginManager():
except:
self.log.debug("Failed to load %s" % name)
continue
-
+
try:
- module = __import__(value["path"], globals(), locals(), [value["name"]] , -1)
+ module = __import__(value["path"], globals(), locals(), [value["name"]], -1)
pluginClass = getattr(module, name)
except Exception, e:
- self.log.error(_("Error importing %(name)s: %(msg)s") % {"name": name, "msg": str(e) })
+ self.log.error(_("Error importing %(name)s: %(msg)s") % {"name": name, "msg": str(e)})
self.log.error(_("You should fix dependicies or deactivate load on startup."))
if self.core.debug:
print_exc()
@@ -298,25 +301,29 @@ class PluginManager():
value["class"] = pluginClass
- classes.append(pluginClass)
-
+ classes.append(pluginClass)
+
return classes
+ def reloadPlugins(self):
+ """ reloads and reindexes plugins """
+ pass
+
if __name__ == "__main__":
- _ = lambda x : x
+ _ = lambda x: x
pypath = "/home/christian/Projekte/pyload-0.4/module/plugins"
-
+
from time import time
-
+
p = PluginManager(None)
-
- a = time()
-
- test = [ "http://www.youtube.com/watch?v=%s" % x for x in range(0,100) ]
+
+ a = time()
+
+ test = ["http://www.youtube.com/watch?v=%s" % x for x in range(0, 100)]
print p.parseUrls(test)
-
+
b = time()
-
- print b-a ,"s"
+
+ print b - a, "s"
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index 02ed9fcb7..9062cb14c 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -31,7 +31,7 @@ class MergeFiles(Hook):
__version__ = "0.1"
__description__ = "Merges parts splitted with hjsplit"
__config__ = [
- ("activated" , "bool" , "Activated" , "True" ),
+ ("activated" , "bool" , "Activated" , "False"),
]
__threaded__ = ["packageFinished"]
__author_name__ = ("and9000")
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index 887aedbd1..df81ebbe7 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -34,14 +34,17 @@ class UpdateManager(Hook):
def setup(self):
self.interval = self.getConfig("interval") * 60
self.updated = False
+ self.reloaded = True
@threaded
def periodical(self):
update = self.checkForUpdate()
if not update:
self.checkPlugins()
- if self.updated:
+ if self.updated and not self.reloaded:
self.log.info(_("*** Plugins have been updated, please restart pyLoad ***"))
+ elif self.updated and self.reloaded:
+ self.log.info(_("Plugins updated and reloaded"))
else:
self.log.info(_("No plugin updates available"))
@@ -103,4 +106,7 @@ class UpdateManager(Hook):
f = open(join("userplugins", prefix, name), "wb")
f.write(content)
f.close()
- self.updated = True \ No newline at end of file
+ self.updated = True
+
+ self.reloaded = False
+ self.core.pluginManager.reloadPlugins() \ No newline at end of file
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py
index fa822493b..5be75a899 100644
--- a/module/plugins/hoster/BitshareCom.py
+++ b/module/plugins/hoster/BitshareCom.py
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
+import re
+
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
-
-import re
+from module.network.RequestFactory import getRequest
def getInfo(urls):
@@ -13,7 +14,7 @@ def getInfo(urls):
for url in urls:
# Get file info html
- req = pyreq.getRequest(BitshareCom.__name__)
+ req = getRequest()
req.cj.setCookie(BitshareCom.HOSTER_DOMAIN, "language_selection", "EN")
html = req.load(url)
req.close()
diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift
index a40cae7a5..8c17c7451 100644
--- a/module/remote/thriftbackend/pyload.thrift
+++ b/module/remote/thriftbackend/pyload.thrift
@@ -13,9 +13,9 @@ enum DownloadStatus {
Offline,
Online,
Queued,
- Checking,
+ Skipped,
Waiting,
- Reconnected,
+ TempOffline,
Starting,
Failed,
Aborted,
diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
index 82ed5bb9a..c207c7bc4 100644
--- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
+++ b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py
@@ -19,9 +19,9 @@ class DownloadStatus:
Offline = 1
Online = 2
Queued = 3
- Checking = 4
+ Skipped = 4
Waiting = 5
- Reconnected = 6
+ TempOffline = 6
Starting = 7
Failed = 8
Aborted = 9
@@ -36,9 +36,9 @@ class DownloadStatus:
1: "Offline",
2: "Online",
3: "Queued",
- 4: "Checking",
+ 4: "Skipped",
5: "Waiting",
- 6: "Reconnected",
+ 6: "TempOffline",
7: "Starting",
8: "Failed",
9: "Aborted",
@@ -54,9 +54,9 @@ class DownloadStatus:
"Offline": 1,
"Online": 2,
"Queued": 3,
- "Checking": 4,
+ "Skipped": 4,
"Waiting": 5,
- "Reconnected": 6,
+ "TempOffline": 6,
"Starting": 7,
"Failed": 8,
"Aborted": 9,