summaryrefslogtreecommitdiffstats
path: root/module/PyFile.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/PyFile.py')
-rw-r--r--module/PyFile.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/module/PyFile.py b/module/PyFile.py
index 3dede9360..4f8b95124 100644
--- a/module/PyFile.py
+++ b/module/PyFile.py
@@ -17,13 +17,12 @@
@author: mkaay
"""
-from module.PullEvents import UpdateEvent
-from module.utils import formatSize, lock
from time import sleep, time
-
from threading import RLock
+from module.utils import formatSize, lock
+
statusMap = {
"finished": 0,
"offline": 1,
@@ -50,16 +49,16 @@ class PyFile(object):
"""
Represents a file object at runtime
"""
- __slots__ = ("m", "id", "url", "name", "size", "_size", "status", "pluginname", "packageid",
+ __slots__ = ("m", "id", "url", "_name", "name", "size", "_size", "status", "pluginname", "packageid",
"error", "order", "lock", "plugin", "waitUntil", "active", "abort", "statusname",
- "reconnected", "progress", "maxprogress", "pluginmodule", "pluginclass")
+ "reconnected", "progress", "maxprogress", "pluginclass")
def __init__(self, manager, id, url, name, size, status, error, pluginname, package, order):
self.m = manager
self.id = int(id)
self.url = url
- self.name = name
+ self._name = name
self.size = size
self.status = status
self.pluginname = pluginname
@@ -90,16 +89,33 @@ class PyFile(object):
# will convert all sizes to ints
size = property(lambda self: self._size, setSize)
-
+
+ def getName(self):
+ try:
+ if self.plugin.req.name:
+ return self.plugin.req.name
+ else:
+ return self._name
+ except:
+ return self._name
+
+ def setName(self, name):
+ """ Only set unicode or utf8 strings as name """
+ if type(name) == str:
+ name = name.decode("utf8")
+
+ self._name = name
+
+ name = property(getName, setName)
+
def __repr__(self):
- return "PyFile %s: %s@%s" % (self.id, self.name, self.pluginname)
+ return "<PyFile %s: %s@%s>" % (self.id, self.name, self.pluginname)
@lock
def initPlugin(self):
""" inits plugin instance """
if not self.plugin:
- self.pluginmodule = self.m.core.pluginManager.getPlugin(self.pluginname)
- self.pluginclass = getattr(self.pluginmodule, self.m.core.pluginManager.getPluginName(self.pluginname))
+ self.pluginclass = self.m.core.pluginManager.getPlugin(self.pluginname)
self.plugin = self.pluginclass(self)
@lock
@@ -276,8 +292,7 @@ class PyFile(object):
return self.size
def notifyChange(self):
- e = UpdateEvent("file", self.id, "collector" if not self.package().queue else "queue")
- self.m.core.pullManager.addEvent(e)
+ self.m.core.eventManager.dispatchEvent("linkUpdated", self.id, self.packageid)
def setProgress(self, value):
if not value == self.progress: