diff options
author | mkaay <mkaay@mkaay.de> | 2010-01-01 17:13:43 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-01-01 17:13:43 +0100 |
commit | 4f904bd9610795c36d9e896bdf44c263ff43f5fd (patch) | |
tree | f232e78de164f9151371e56146439d34fbe28802 | |
parent | removed prints (diff) | |
download | pyload-4f904bd9610795c36d9e896bdf44c263ff43f5fd.tar.xz |
fixed SerienjunkiesOrg, no more segfault in gui?
-rw-r--r-- | module/file_list.py | 2 | ||||
-rw-r--r-- | module/gui/Collector.py | 58 | ||||
-rw-r--r-- | module/gui/MainWindow.py | 2 | ||||
-rw-r--r-- | module/gui/Queue.py | 38 | ||||
-rw-r--r-- | module/plugins/decrypter/SerienjunkiesOrg.py | 4 |
5 files changed, 71 insertions, 33 deletions
diff --git a/module/file_list.py b/module/file_list.py index 8af66d5ed..232f2b7ea 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -127,7 +127,7 @@ class File_List(object): for thread_list only """ files = [] - for pypack in self.data["queue"] + self.data["packages"]: + for pypack in self.data["queue"]: for pyfile in pypack.files: if pyfile.status.type == None and pyfile.plugin.props['type'] == "container" and not pyfile.active: files.append(pyfile) diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 356ab36ec..112eb1cd5 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -23,14 +23,13 @@ from time import sleep from module.gui.Queue import ItemIterator -class PackageCollector(QThread): +class PackageCollector(QObject): def __init__(self, view, connector): - QThread.__init__(self) + QObject.__init__(self) self.view = view self.connector = connector self.collector = [] self.interval = 2 - self.running = True self.rootItem = self.view.invisibleRootItem() self.mutex = QMutex() item = self.PackageCollectorPack(self) @@ -40,14 +39,28 @@ class PackageCollector(QThread): self.rootItem.addChild(item) self.linkCollector = item self.pauseIDs = [] + self.updater = self.CollectorUpdater(self.interval) + self.connect(self.updater, SIGNAL("update()"), self.update) - def run(self): - while self.running: - self.update() - sleep(self.interval) + class CollectorUpdater(QThread): + def __init__(self, interval): + QThread.__init__(self) + self.interval = interval + self.running = True + + def run(self): + while self.running: + self.emit(SIGNAL("update()")) + self.sleep(self.interval) + + def start(self): + self.updater.start() + + def wait(self): + self.updater.wait() def stop(self): - self.running = False + self.updater.running = False def update(self): locker = QMutexLocker(self.mutex) @@ -210,23 +223,36 @@ class PackageCollector(QThread): def getPack(self): return self.pack -class LinkCollector(QThread): +class LinkCollector(QObject): def __init__(self, view, root, connector): - QThread.__init__(self) + QObject.__init__(self) self.view = view self.connector = connector self.interval = 2 - self.running = True self.rootItem = root self.mutex = QMutex() + self.updater = self.CollectorUpdater(self.interval) + self.connect(self.updater, SIGNAL("update()"), self.update) + + class CollectorUpdater(QThread): + def __init__(self, interval): + QThread.__init__(self) + self.interval = interval + self.running = True + + def run(self): + while self.running: + self.emit(SIGNAL("update()")) + self.sleep(self.interval) + + def start(self): + self.updater.start() - def run(self): - while self.running: - self.update() - sleep(self.interval) + def wait(self): + self.updater.wait() def stop(self): - self.running = False + self.updater.running = False def update(self): locker = QMutexLocker(self.mutex) diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index 94ff63dda..250b701e4 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -403,13 +403,11 @@ class MainWindow(QMainWindow): def slotEditPackage(self): item = self.tabs["collector"]["package_view"].currentItem() pid = self.tabs["collector"]["package_view"].currentItem().data(0, Qt.UserRole).toPyObject() - print type(pid) self.emit(SIGNAL("pauseItemUpdate"), pid, True) self.tabs["collector"]["package_view"].editItem(item, 0) def slotCloseItemEditor(self, editor, hint): pid = self.tabs["collector"]["package_view"].currentItem().data(0, Qt.UserRole).toPyObject() - print type(pid) self.emit(SIGNAL("changePackageName"), pid, editor.text()) self.emit(SIGNAL("pauseItemUpdate"), pid, False) diff --git a/module/gui/Queue.py b/module/gui/Queue.py index 499cb5199..ed1c0f0a1 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -21,9 +21,9 @@ from PyQt4.QtGui import * from time import sleep, time -class Queue(QThread): +class Queue(QObject): def __init__(self, view, connector): - QThread.__init__(self) + QObject.__init__(self) self.view = view self.connector = connector self.statusMap = { @@ -33,24 +33,38 @@ class Queue(QThread): "waiting": 3, "reconnected": 4, "starting": 5, - "downloading": 6, - "failed": 7, - "aborted": 8, + "failed": 6, + "aborted": 7, + "decrypting": 8, + "downloading": 9 } self.statusMapReverse = dict((v,k) for k, v in self.statusMap.iteritems()) self.interval = 1 - self.running = True self.wait_dict = {} self.rootItem = self.view.invisibleRootItem() self.mutex = QMutex() + self.updater = self.QueueUpdater(self.interval) + self.connect(self.updater, SIGNAL("update()"), self.update) - def run(self): - while self.running: - self.update() - sleep(self.interval) + class QueueUpdater(QThread): + def __init__(self, interval): + QThread.__init__(self) + self.interval = interval + self.running = True + + def run(self): + while self.running: + self.emit(SIGNAL("update()")) + self.sleep(self.interval) + + def start(self): + self.updater.start() + + def wait(self): + self.updater.wait() def stop(self): - self.running = False + self.updater.running = False def update(self): locker = QMutexLocker(self.mutex) @@ -241,7 +255,7 @@ class Queue(QThread): self.addChild(newChild) item = newChild speed = self.queue.getSpeed(item) - if speed == None or item.getFileData()["status_type"] == "starting": + if speed == None or item.getFileData()["status_type"] == "starting" or item.getFileData()["status_type"] == "decrypting": status = item.getFileData()["status_type"] else: status = "%s (%s KB/s)" % (item.getFileData()["status_type"], speed) diff --git a/module/plugins/decrypter/SerienjunkiesOrg.py b/module/plugins/decrypter/SerienjunkiesOrg.py index ce1721e92..2f77b81ae 100644 --- a/module/plugins/decrypter/SerienjunkiesOrg.py +++ b/module/plugins/decrypter/SerienjunkiesOrg.py @@ -52,7 +52,7 @@ class SerienjunkiesOrg(Plugin): self.hosterMapReverse = dict((v,k) for k, v in self.hosterMap.iteritems()) episodePattern = re.compile("^http://download.serienjunkies.org/f-.*?.html$") oldStyleLink = re.compile("^http://serienjunkies.org/safe/(.*)$") - if re.match(episodePattern, self.parent.url) or re.match(oldStyleLink, self.parent.url): + if episodePattern.match(self.parent.url) or oldStyleLink.match(self.parent.url): self.decryptNow = False else: self.decryptNow = True @@ -121,7 +121,7 @@ class SerienjunkiesOrg(Plugin): val = v.nextSibling val = val.encode("utf-8") val = decode_htmlentities(val) - val = val.replace(" |", "") + val = val.replace("|", "").strip() n = n.strip() n = re.sub(r"^([:]?)(.*?)([:]?)$", r'\2', n) val = val.strip() |