summaryrefslogtreecommitdiffstats
path: root/module/download_thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/download_thread.py')
-rw-r--r--module/download_thread.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/module/download_thread.py b/module/download_thread.py
index 4a031a04c..7c899b185 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -1,28 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-#
-#Copyright (C) 2009 sp00b, sebnapi
-#
-#This program is free software; you can redistribute it and/or modify
-#it under the terms of the GNU General Public License as published by
-#the Free Software Foundation; either version 3 of the License,
-#or (at your option) any later version.
-#
-#This program is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#See the GNU General Public License for more details.
-#
-#You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-###
+
+"""
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: mkaay
+ @author: spoob
+ @author: sebnapi
+ @version: v0.3
+"""
+
import threading
import traceback
from os.path import join
from time import sleep, time
from module.network.Request import AbortDownload
+from module.PullEvents import UpdateEvent
class Status(object):
""" Saves all status information
@@ -107,15 +112,16 @@ class Download_Thread(threading.Thread):
code, msg = e
if code == 7:
sleep(60)
- self.parent.parent.logger.info("Hoster unvailable, wait 60 seconds")
+ self.parent.parent.logger.info(_("Hoster unvailable, wait 60 seconds"))
except Exception, f:
- self.parent.parent.logger.debug("Error getting error code: "+ str(f))
+ self.parent.parent.logger.debug(_("Error getting error code: %s") % f)
if self.parent.parent.config['general']['debug_mode']:
traceback.print_exc()
self.loadedPyFile.status.type = "failed"
self.loadedPyFile.status.error = str(e)
finally:
self.parent.job_finished(self.loadedPyFile)
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", self.loadedPyFile.id, "queue"))
else:
sleep(3)
sleep(0.8)
@@ -126,6 +132,7 @@ class Download_Thread(threading.Thread):
def download(self, pyfile):
status = pyfile.status
status.type = "starting"
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue"))
pyfile.init_download()
@@ -136,6 +143,7 @@ class Download_Thread(threading.Thread):
status.type = "decrypting"
else:
status.type = "downloading"
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue"))
location = join(pyfile.folder, status.filename)
pyfile.plugin.proceed(status.url, location)
@@ -152,13 +160,13 @@ class Download_Thread(threading.Thread):
20 - unknown error
"""
if code == 0:
- self.parent.parent.logger.info("Checksum ok ('%s')" % status.filename)
+ self.parent.parent.logger.info(_("Checksum ok ('%s')") % status.filename)
elif code == 1:
- self.parent.parent.logger.info("Checksum not matched! ('%s')" % status.filename)
+ self.parent.parent.logger.info(_("Checksum not matched! ('%s')") % status.filename)
elif code == 5:
- self.parent.parent.logger.debug("Can't get checksum for %s" % status.filename)
+ self.parent.parent.logger.debug(_("Can't get checksum for %s") % status.filename)
elif code == 10:
- self.parent.parent.logger.debug("Checksum not implemented for %s" % status.filename)
+ self.parent.parent.logger.debug(_("Checksum not implemented for %s") % status.filename)
if not check:
raise Checksum(code, location)