summaryrefslogtreecommitdiffstats
path: root/pyload/datatypes
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-29 18:51:38 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-29 18:51:38 +0100
commit3401bcfd5ed57dec9e0f78553d627d7608170cb6 (patch)
treec36ac6fe4581379ed03f72409244aa40414b9580 /pyload/datatypes
parentfixed new waiting dl rule (diff)
downloadpyload-3401bcfd5ed57dec9e0f78553d627d7608170cb6.tar.xz
added connection flags to download status
Diffstat (limited to 'pyload/datatypes')
-rw-r--r--pyload/datatypes/PyFile.py43
1 files changed, 18 insertions, 25 deletions
diff --git a/pyload/datatypes/PyFile.py b/pyload/datatypes/PyFile.py
index 5e5d56d17..80926ae11 100644
--- a/pyload/datatypes/PyFile.py
+++ b/pyload/datatypes/PyFile.py
@@ -20,7 +20,7 @@ from time import sleep, time
from ReadWriteLock import ReadWriteLock
from pyload.Api import ProgressInfo, ProgressType, DownloadProgress, FileInfo, DownloadInfo, DownloadStatus
-from pyload.utils import lock, read_lock
+from pyload.utils import lock, read_lock, try_catch
from pyload.utils.fs import safe_filename
from pyload.utils.filetypes import guess_type
@@ -48,7 +48,6 @@ statusMap = {
"unknown": 20,
}
-
class PyFile(object):
"""
Represents a file object at runtime
@@ -192,8 +191,7 @@ class PyFile(object):
def toInfoData(self):
return FileInfo(self.fid, self.getName(), self.packageid, self.owner, self.getSize(), self.filestatus,
self.media, self.added, self.fileorder, DownloadInfo(
- self.url, self.pluginname, self.hash, self.status, self.getStatusName(), self.error
- )
+ self.url, self.pluginname, self.hash, self.status, self.getStatusName(), self.error)
)
def getPath(self):
@@ -204,7 +202,6 @@ class PyFile(object):
def abortDownload(self):
"""abort pyfile if possible"""
- # TODO: abort timeout, currently dead locks
while self.fid in self.m.core.dlm.processingIds():
self.lock.acquire(shared=True)
@@ -236,36 +233,28 @@ class PyFile(object):
def checkIfProcessed(self):
self.m.checkAllLinksProcessed(self.id)
+ @try_catch(0)
def getSpeed(self):
""" calculates speed """
- try:
- return self.plugin.dl.speed
- except:
- return 0
+ return self.plugin.dl.speed
+ @try_catch(0)
def getETA(self):
- """ gets established time of arrival / or waiting time"""
- try:
- if self.status == DownloadStatus.Waiting:
- return self.waitUntil - time()
+ """ gets estimated time of arrival / or waiting time"""
+ if self.status == DownloadStatus.Waiting:
+ return self.waitUntil - time()
- return self.getBytesLeft() / self.getSpeed()
- except:
- return 0
+ return self.getBytesLeft() / self.getSpeed()
+ @try_catch(0)
def getBytesArrived(self):
""" gets bytes arrived """
- try:
- return self.plugin.dl.arrived
- except:
- return 0
+ return self.plugin.dl.arrived
+ @try_catch(0)
def getBytesLeft(self):
""" gets bytes left """
- try:
- return self.plugin.dl.size - self.plugin.dl.arrived
- except:
- return 0
+ return self.plugin.dl.size - self.plugin.dl.arrived
def getSize(self):
""" get size of download """
@@ -277,7 +266,11 @@ class PyFile(object):
except:
return self.size
+ @try_catch(0)
+ def getFlags(self):
+ return self.plugin.dl.flags
+
def getProgressInfo(self):
return ProgressInfo(self.pluginname, self.name, self.getStatusName(), self.getETA(),
self.getBytesArrived(), self.getSize(), self.owner, ProgressType.Download,
- DownloadProgress(self.fid, self.packageid, self.getSpeed(), self.status))
+ DownloadProgress(self.fid, self.packageid, self.getSpeed(), self.getFlags(), self.status))