summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-11-26 21:50:02 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-11-26 21:50:02 +0100
commitd43b66838414e219b7ffecfe917b7d4a8354418e (patch)
treebea2492aa4840be34a53bd26064f4c333d25790e
parentinvoke addons via context menu (diff)
downloadpyload-d43b66838414e219b7ffecfe917b7d4a8354418e.tar.xz
extraction via context menu + progress information working
-rw-r--r--pyload/plugins/addons/ExtractArchive.py2
-rw-r--r--pyload/plugins/hoster/BasePlugin.py10
-rw-r--r--pyload/threads/AddonThread.py14
-rw-r--r--pyload/threads/BaseThread.py4
-rw-r--r--pyload/threads/ThreadManager.py7
5 files changed, 25 insertions, 12 deletions
diff --git a/pyload/plugins/addons/ExtractArchive.py b/pyload/plugins/addons/ExtractArchive.py
index c3c5dbeb7..62c947f88 100644
--- a/pyload/plugins/addons/ExtractArchive.py
+++ b/pyload/plugins/addons/ExtractArchive.py
@@ -210,7 +210,7 @@ class ExtractArchive(Addon):
thread.addActive(pyfile) # keep this file until everything is done
try:
- progress = lambda x: pyfile.setProgress(x)
+ progress = lambda x: thread.setProgress(x)
success = False
if not plugin.checkArchive():
diff --git a/pyload/plugins/hoster/BasePlugin.py b/pyload/plugins/hoster/BasePlugin.py
index 2bdfda7c4..50d1f229b 100644
--- a/pyload/plugins/hoster/BasePlugin.py
+++ b/pyload/plugins/hoster/BasePlugin.py
@@ -4,9 +4,9 @@ from urlparse import urlparse
from re import search
from urllib import unquote
-from module.network.HTTPRequest import BadHeader
-from module.plugins.Hoster import Hoster
-from module.utils import html_unescape, remove_chars
+from pyload.plugins.Request import ResponseException
+from pyload.plugins.Hoster import Hoster
+from pyload.utils import html_unescape, remove_chars
class BasePlugin(Hoster):
@@ -45,7 +45,7 @@ class BasePlugin(Hoster):
try:
self.downloadFile(pyfile)
- except BadHeader, e:
+ except ResponseException, e:
if e.code in (401, 403):
self.logDebug("Auth required")
@@ -79,7 +79,7 @@ class BasePlugin(Hoster):
# self.load does not raise a BadHeader on 404 responses, do it here
if 'code' in header and header['code'] == 404:
- raise BadHeader(404)
+ raise ResponseException(404)
if 'location' in header:
self.logDebug("Location: " + header['location'])
diff --git a/pyload/threads/AddonThread.py b/pyload/threads/AddonThread.py
index afb56f66b..fd613bdec 100644
--- a/pyload/threads/AddonThread.py
+++ b/pyload/threads/AddonThread.py
@@ -4,6 +4,7 @@
from copy import copy
from traceback import print_exc
+from pyload.Api import ProgressInfo
from BaseThread import BaseThread
class AddonThread(BaseThread):
@@ -18,6 +19,7 @@ class AddonThread(BaseThread):
self.kwargs = kwargs
self.active = []
+ self.progress = 0
m.localThreads.append(self)
@@ -26,6 +28,18 @@ class AddonThread(BaseThread):
def getActiveFiles(self):
return self.active
+ # TODO: multiple progresses
+ def setProgress(self, progress, pyfile=None):
+ """ Sets progress for the thread in percent"""
+ self.progress = progress
+
+ def getProgress(self):
+ """ Progress of the thread """
+ if self.active:
+ active = self.active[0]
+ return ProgressInfo(active.pluginname, active.name, active.getStatusName(), 0,
+ self.progress, 100)
+
def addActive(self, pyfile):
""" Adds a pyfile to active list and thus will be displayed on overview"""
if pyfile not in self.active:
diff --git a/pyload/threads/BaseThread.py b/pyload/threads/BaseThread.py
index 3655480dd..9b4e5af67 100644
--- a/pyload/threads/BaseThread.py
+++ b/pyload/threads/BaseThread.py
@@ -16,7 +16,7 @@ from pyload.setup.system import get_system_info
class BaseThread(Thread):
"""abstract base class for thread types"""
- def __init__(self, manager, ower=None):
+ def __init__(self, manager, owner=None):
Thread.__init__(self)
self.setDaemon(True)
self.m = manager #thread manager
@@ -24,7 +24,7 @@ class BaseThread(Thread):
self.log = manager.core.log
#: Owner of the thread, every type should set it or overwrite user
- self.owner = None
+ self.owner = owner
@property
def user(self):
diff --git a/pyload/threads/ThreadManager.py b/pyload/threads/ThreadManager.py
index 55cfcbfd2..3132e98e2 100644
--- a/pyload/threads/ThreadManager.py
+++ b/pyload/threads/ThreadManager.py
@@ -27,7 +27,7 @@ from random import choice
from pyload.datatypes.PyFile import PyFile
from pyload.datatypes.OnlineCheck import OnlineCheck
from pyload.network.RequestFactory import getURL
-from pyload.utils import lock, uniqify
+from pyload.utils import lock, uniqify, to_list
from pyload.utils.fs import free_space
from DecrypterThread import DecrypterThread
@@ -118,13 +118,12 @@ class ThreadManager:
def getProgressList(self, user=None):
info = []
- # TODO: local threads can create multiple progresses
for thread in self.threads + self.localThreads:
# skip if not belong to current user
- if user and thread.user != user: continue
+ if user is not None and thread.owner != user: continue
progress = thread.getProgress()
- if progress: info.append(progress)
+ if progress: info.extend(to_list(progress))
return info