summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-12 00:52:10 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-12 00:52:10 +0100
commit8be6df43e1d3ae274ee8002588b650ec181a05f6 (patch)
tree6a2077411e2587673c0045434c9f115887c1b17e
parentFix JsEngine (diff)
downloadpyload-8be6df43e1d3ae274ee8002588b650ec181a05f6.tar.xz
Spare code fixes (2)
-rw-r--r--pyload/manager/AddonManager.py2
-rw-r--r--pyload/manager/PluginManager.py25
-rw-r--r--pyload/manager/ThreadManager.py4
-rw-r--r--pyload/network/Bucket.py5
-rw-r--r--pyload/network/HTTPDownload.py8
5 files changed, 23 insertions, 21 deletions
diff --git a/pyload/manager/AddonManager.py b/pyload/manager/AddonManager.py
index 0fc3efb7b..2fd744776 100644
--- a/pyload/manager/AddonManager.py
+++ b/pyload/manager/AddonManager.py
@@ -46,6 +46,8 @@ class AddonManager(object):
"""
def __init__(self, core):
+ self.core = core
+
__builtin__.addonManager = self #: needed to let addons register themself
self.plugins = []
diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py
index 92b5e2c7d..c327c991a 100644
--- a/pyload/manager/PluginManager.py
+++ b/pyload/manager/PluginManager.py
@@ -16,9 +16,9 @@ from SafeEval import const_eval as literal_eval
class PluginManager(object):
- ROOT = "pyload.plugins."
+ ROOT = "pyload.plugins."
USERROOT = "userplugins."
- TYPES = []
+ TYPES = ["account", "addon", "container", "crypter", "hook", "hoster", "internal", "ocr"]
PATTERN = re.compile(r'__pattern\s*=\s*u?r("|\')([^"\']+)')
VERSION = re.compile(r'__version\s*=\s*("|\')([\d.]+)')
@@ -36,15 +36,17 @@ class PluginManager(object):
sys.meta_path.append(self)
- def initTYPES(self):
+ def loadTypes(self):
rootdir = join(pypath, "pyload", "plugins")
userdir = "userplugins"
- tmpset = set()
- for p in (rootdir, userdir):
- tmpset += set([d for d in listdir(p) if isdir(join(p, d))])
+ types = set().union(*[[d for d in listdir(p) if isdir(join(p, d))]
+ for p in (rootdir, userdir) if exists(p)])
- self.TYPES = list(tmpset)
+ if not types:
+ self.log.critical(_("No plugins found!"))
+
+ self.TYPES = list(set(self.TYPES) | types)
def createIndex(self):
@@ -52,16 +54,13 @@ class PluginManager(object):
sys.path.append(abspath(""))
- self.initTYPES()
-
- if not self.TYPES:
- self.log.critical(_("No TYPES, no fun!"))
+ self.loadTypes()
- for type in set(self.TYPES):
+ for type in self.TYPES:
self.plugins[type] = self.parse(type)
setattr(self, "%sPlugins" % type, self.plugins[type])
- self.plugins['addon'] = self.addonPlugins.extend(self.hookPlugins)
+ self.plugins['addon'] = self.addonPlugins.update(self.hookPlugins)
self.core.log.debug("Created index of plugins")
diff --git a/pyload/manager/ThreadManager.py b/pyload/manager/ThreadManager.py
index 7e7854b75..d6f3c0005 100644
--- a/pyload/manager/ThreadManager.py
+++ b/pyload/manager/ThreadManager.py
@@ -11,7 +11,9 @@ from random import choice
import pycurl
-from pyload.manager.thread import DecrypterThread, DownloadThread, InfoThread
+from pyload.manager.thread.DecrypterThread import DecrypterThread
+from pyload.manager.thread.DownloadThread import DownloadThread
+from pyload.manager.thread.InfoThread import InfoThread
from pyload.datatype.PyFile import PyFile
from pyload.network.RequestFactory import getURL
from pyload.utils import freeSpace, lock
diff --git a/pyload/network/Bucket.py b/pyload/network/Bucket.py
index 33aa7c42e..408a1e240 100644
--- a/pyload/network/Bucket.py
+++ b/pyload/network/Bucket.py
@@ -2,10 +2,9 @@
# @author: RaNaN
from time import time
+from threading import Lock
-
-# 10kb minimum rate
-MIN_RATE = 10240
+MIN_RATE = 10240 #: 10kb minimum rate
class Bucket(object):
diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py
index 270e81795..65c893ad7 100644
--- a/pyload/network/HTTPDownload.py
+++ b/pyload/network/HTTPDownload.py
@@ -19,7 +19,7 @@ class HTTPDownload(object):
""" loads a url http + ftp """
def __init__(self, url, filename, get={}, post={}, referer=None, cj=None, bucket=None,
- options={}, progressNotify=None, disposition=False):
+ options={}, progress=None, disposition=False):
self.url = url
self.filename = filename #complete file destination, not only name
self.get = get
@@ -55,7 +55,7 @@ class HTTPDownload(object):
self.speeds = []
self.lastSpeeds = [0, 0]
- self.progressNotify = progressNotify
+ self.progress = progress
@property
def speed(self):
@@ -280,8 +280,8 @@ class HTTPDownload(object):
self._copyChunks()
def updateProgress(self):
- if self.progressNotify:
- self.progressNotify(self.percent)
+ if self.progress:
+ self.progress(self.percent)
def findChunk(self, handle):
""" linear search to find a chunk (should be ok since chunk size is usually low) """