diff options
| author | 2010-07-29 17:05:45 +0200 | |
|---|---|---|
| committer | 2010-07-29 17:05:45 +0200 | |
| commit | 252cf9964a2ebc78a589f75db2a7be0d25cac512 (patch) | |
| tree | 0f4cd1a7949f8a3dc87eaed35f248170ee421943 | |
| parent | many new stuff, some things already working (diff) | |
| download | pyload-252cf9964a2ebc78a589f75db2a7be0d25cac512.tar.xz | |
more improvements and cleaned some imports
26 files changed, 169 insertions, 173 deletions
| diff --git a/module/ConfigParser.py b/module/ConfigParser.py index 974986093..e37d3f521 100644 --- a/module/ConfigParser.py +++ b/module/ConfigParser.py @@ -241,6 +241,7 @@ class ConfigParser:      def set(self, section, option, value):          """set value"""          self.config[section][option]["value"] = value +        self.save()      #----------------------------------------------------------------------      def getPlugin(self, plugin, option): @@ -251,7 +252,26 @@ class ConfigParser:      def setPlugin(self, plugin, option, value):          """sets a value for a plugin"""          self.plugin[plugin][option]["value"] = value +        self.save() +    #---------------------------------------------------------------------- +    def addPluginConfig(self, config): +        """adds config option with tuple (plugin, name, type, desc, default)""" +         +        if not self.plugin.has_key(config[0]): +            self.plugin[config[0]] = { "desc" : config[0], +                                       config[1] : { +                                           "desc" : config[3], +                                           "typ" : config[2], +                                           "value" : config[4] +                                       } } +        else: +            if not self.plugin[config[0]].has_key(config[1]): +                self.plugin[config[0]][config[1]] = { +                                           "desc" : config[3], +                                           "typ" : config[2], +                                           "value" : config[4] +                                       }  ########################################################################  class Section: @@ -272,13 +292,13 @@ class Section:      def __setitem__(self, item, value):          """setitem"""          self.parser.set(self.section, item, value) -     +  if __name__ == "__main__":      pypath = "" -    from time import time,sleep +    from time import time      a = time() diff --git a/module/FileDatabase.py b/module/FileDatabase.py index 843121492..77f1fde9e 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -21,7 +21,6 @@ from threading import Thread  from threading import RLock  from time import sleep  from time import time -from os import path  import traceback  statusMap = { @@ -88,9 +87,6 @@ class FileHandler:  		data = self.db.getAllLinks(queue)  		packs = self.db.getAllPackages(queue) - -		print data -		print packs  		data.update( [ (x.id, x.toDbDict()[x.id]) for x in self.cache.itervalues() ] )  		packs.update( [ (x.id, x.toDict()[x.id]) for x in self.packageCache.itervalues() if x.queue == queue] ) @@ -132,7 +128,7 @@ class FileHandler:  		for pyfile in self.cache.itervalues():  			if pyfile.packageid == id: -				pyfile.abort() +				pyfile.abortDownload()  				toDelete.append(pyfile.id)  		for pid in toDelete: @@ -151,7 +147,7 @@ class FileHandler:  		self.lock.acquire()  		if self.cache.has_key(id): -			self.cache[id].abort() +			self.cache[id].abortDownload()  			del self.cache[id]  		self.lock.release() @@ -403,7 +399,7 @@ class FileDatabaseBackend(Thread):  	@async  	def updateLink(self, f): -		self.c.execute('UPDATE links SET url=?,name=?,size=?,status=?,error=?,package=? WHERE id=?', (f.name, f.url, f.size, f.status, f.error, str(f.packageid), str(f.id))) +		self.c.execute('UPDATE links SET url=?,name=?,size=?,status=?,error=?,package=? WHERE id=?', (f.url, f.name, f.size, f.status, f.error, str(f.packageid), str(f.id)))  	@async  	def updatePackage(self, p): @@ -434,7 +430,7 @@ class FileDatabaseBackend(Thread):  	@queue  	def getJob(self, occ):  		"""return pyfile instance, which is suitable for download and dont use a occupied plugin""" -		self.c.execute("SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN ('else','some','else') AND l.status IN (2,3,6) LIMIT 5") +		self.c.execute("SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6) LIMIT 5" % str(occ)) # very bad!  		return [x[0] for x in self.c ] @@ -452,6 +448,8 @@ class PyFile():  		self.packageid = package #should not be used, use package() instead  		self.error = error  		# database information ends here +		 +		self.plugin = None  		self.waitUntil = 0 # time() + time to wait @@ -514,7 +512,7 @@ class PyFile():  				'url': self.url,  				'name': self.name,  		        'plugin' : self.pluginname, -				'size': self.size, +				'size': self.getSize(),  				'status': self.status,  		        'statusmsg': self.m.statusMsg[self.status],  				'package': self.packageid, @@ -522,14 +520,17 @@ class PyFile():  			}  		} -	def abort(self): +	def abortDownload(self):  		"""abort pyfile if possible""" +		print "abort" -		while self.id in self.m.core.ThreadManager.processingIds(): +		while self.id in self.m.core.threadManager.processingIds():  			self.abort = True -			sleep(0.025) -			 +			if self.plugin: self.plugin.req.abort = True +			sleep(0.1) +		  		abort = False  +		self.plugin.req.abort = False  	def finishIfDone(self):  		"""set status to finish and release file if every thread is finished with it""" @@ -544,8 +545,43 @@ class PyFile():  	def formatWait(self):  		""" formats and return wait time in humanreadable format """  		return self.waitUntil - time() +	 +	def getSpeed(self): +		""" calculates speed """ +		try: +			return self.plugin.req.get_speed() +		except: +			return 0 - +	def getETA(self): +		""" gets established time of arrival""" +		try: +			return self.plugin.req.get_ETA() +		except: +			return 0 +	 +	def getKbLeft(self): +		""" gets kb left """ +		try: +			return self.plugin.req.kB_left() +		except: +			return 0 +	 +	def getPercent(self): +		""" get % of download """ +		try: +			return int((float(self.plugin.req.dl_arrived)  / self.plugin.req.dl_size) * 100) +		except: +			return 0 +		 +	def getSize(self): +		""" get size of download """ +		if self.size: return self.size +		else: +			try: +				return self.plugin.req.dl_size +			except: +				return 0  class PyPackage():  	def __init__(self, manager, id, name, folder, site, password, queue): diff --git a/module/FileList.py b/module/FileList.py index b785af6de..6a43f7d54 100644 --- a/module/FileList.py +++ b/module/FileList.py @@ -26,13 +26,11 @@ LIST_VERSION = 4  from operator import attrgetter  from operator import concat  from os.path import join -import re  from threading import RLock  from time import sleep  import cPickle  from module.DownloadThread import Status -import module.plugins.Plugin  from module.PullEvents import InsertEvent  from module.PullEvents import RemoveEvent  from module.PullEvents import UpdateEvent diff --git a/module/HookManager.py b/module/HookManager.py index 2d81d87b3..96815ef63 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -18,7 +18,6 @@      @interface-version: 0.1  """ -import logging  import traceback  from threading import RLock @@ -47,11 +46,13 @@ class HookManager():          plugins = []          for pluginClass in self.core.pluginManager.getHookPlugins():              try: +                #hookClass = getattr(plugin, plugin.__name__) +                #@TODO config parsing and deactivating                  plugin = pluginClass(self.core) -                plugin.readConfig()                  plugins.append(plugin) +                self.log.info(_("%s activated") % pluginClass.__name__)              except: -                #self.log.warning(_("Failed activating %(name)s") % {"name":plugin.__name__}) +                self.log.warning(_("Failed activating %(name)s") % {"name":pluginClass.__name__})                  if self.core.debug:                      traceback.print_exc() diff --git a/module/InitHomeDir.py b/module/InitHomeDir.py index aa94f698c..a3fc64e50 100644 --- a/module/InitHomeDir.py +++ b/module/InitHomeDir.py @@ -37,7 +37,6 @@ try:  except ImportError: # quick semi-nasty fallback for non-windows/win32com case  	if platform == 'nt':  		import ctypes -		from ctypes import wintypes, windll  		CSIDL_APPDATA = 26  		_SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW  		_SHGetFolderPath.argtypes = [ctypes.wintypes.HWND, diff --git a/module/PluginManager.py b/module/PluginManager.py index b56626d0f..cdb3548cb 100644 --- a/module/PluginManager.py +++ b/module/PluginManager.py @@ -18,7 +18,6 @@  """  import re -from threading import Lock  from os import listdir  from os.path import isfile @@ -26,7 +25,6 @@ from os.path import join  from sys import version_info  from itertools import chain -import traceback  class PluginManager():      def __init__(self, core): @@ -50,6 +48,7 @@ class PluginManager():      #----------------------------------------------------------------------      def createHomeDirs(self):          """create homedirectories containing plugins""" +        #@TODO implement...          pass      def createIndex(self): @@ -132,9 +131,10 @@ class PluginManager():                  if config:                      config = [ [y.strip() for y in x.replace("'","").replace('"',"").replace(")","").split(",") if y.strip()] for x in config[0].split("(") if x.strip()] -                    #@TODO: create config +                    for item in config: +                        self.core.config.addPluginConfig([name]+item) -        #@TODO replace with plugins in homedir                     +        #@TODO replace with plugins in homedir, plugin updater                              return plugins diff --git a/module/PluginThread.py b/module/PluginThread.py index 75b643408..313183cca 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -36,7 +36,7 @@ class PluginThread(Thread):  		"""Constructor"""  		Thread.__init__(self)  		self.setDaemon(True) -		self.m = manager +		self.m = manager #thread manager  ######################################################################## @@ -64,7 +64,7 @@ class DownloadThread(PluginThread):  			if self.active == "quit":  				return True -			print pyfile +			self.m.log.info(_("starting %s" % pyfile.name))  			try:  				pyfile.plugin.preprocessing(self) @@ -105,7 +105,7 @@ class DownloadThread(PluginThread):  					self.m.log.warning(_("%s is offline.") % pyfile.name)  				else:  					pyfile.setStatus("failed") -					self.m.log.warning(_("%s failed with message: %s") % (pyfile.name, msg)) +					self.m.log.warning(_("%s failed: %s") % (pyfile.name, msg))  					pyfile.error = msg  				continue @@ -115,9 +115,9 @@ class DownloadThread(PluginThread):  				print "pycurl error", code, msg  				continue -			except Exception,e : +			except Exception, e:  				pyfile.setStatus("failed") -				self.m.log.error(_("%s failed with message: .") % (pyfile.name, str(e))) +				self.m.log.error(_("%s failed: %s") % (pyfile.name, str(e)))  				if self.m.core.debug:  					print_exc() @@ -126,16 +126,17 @@ class DownloadThread(PluginThread):  			finally: -				print "saved"  				self.m.core.files.save() -			print "finished successfully" +			 +			self.m.log(_("%s finished") % pyfile.name)  			#@TODO hooks, packagaefinished etc  			self.active = False	  			pyfile.finishIfDone() +			self.m.core.files.save()  	#----------------------------------------------------------------------  	def put(self, job): diff --git a/module/RequestFactory.py b/module/RequestFactory.py index 373eeb312..6ae6bd146 100644 --- a/module/RequestFactory.py +++ b/module/RequestFactory.py @@ -22,7 +22,6 @@ from module.network.Request import Request  from module.network.XdccRequest import XdccRequest  from module.network.FtpRequest import FtpRequest  from time import time -import pycurl  class RequestFactory():      def __init__(self, core): diff --git a/module/network/FtpRequest.py b/module/network/FtpRequest.py index a2f83d0fc..026d0f9fc 100644 --- a/module/network/FtpRequest.py +++ b/module/network/FtpRequest.py @@ -21,9 +21,8 @@      @version: v0.3.2  """ -import base64  import time -from os import sep, rename, stat +from os import rename  from os.path import exists  from cStringIO import StringIO  import pycurl diff --git a/module/network/Request.py b/module/network/Request.py index 4649c712a..f3e399c1d 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -29,8 +29,7 @@ import urllib  from cStringIO import StringIO  import pycurl -class AbortDownload(Exception): -    pass +from module.plugins.Plugin import Abort  class Request:      def __init__(self, interface=None): @@ -191,7 +190,7 @@ class Request:          self.pycurl.setopt(pycurl.COOKIELIST, "")      def add_proxy(self, protocol, adress): -        # @TODO: pycurl proxy protocoll selection +        # @TODO: pycurl proxy protocol selection          self.pycurl.setopt(pycurl.PROXY, adress.split(":")[0])          self.pycurl.setopt(pycurl.PROXYPORT, adress.split(":")[1]) @@ -292,6 +291,7 @@ class Request:          self.addCookies()          self.fp.close() +        if self.abort: raise Abort          free_name = self.get_free_name(folder, file_name)          move(file_temp, free_name) diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 45435b2f6..ed62cbdb2 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -18,7 +18,6 @@      @interface-version: 0.2  """ -import logging  class Hook(): @@ -26,26 +25,17 @@ class Hook():      __version__ = "0.2"      __type__ = "hook"      __description__ = """interface for hook""" -    __author_name__ = ("mkaay") -    __author_mail__ = ("mkaay@mkaay.de") +    __author_name__ = ("mkaay", "RaNaN") +    __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org")      def __init__(self, core): -        self.logger = logging.getLogger("log") -        self.configParser = core.parser_plugins -        self.config = {} -        self.core = core -     -    def readConfig(self): -        self.configParser.loadData() -        section = self.__name__ -        try: -            self.config = self.configParser.getConfig()[section] -        except: -            self.setup() -     +        self.core = core  +        self.log = core.log +         +        self.setup() +                     def setup(self): -        self.configParser.set(self.__name__, {"option": "activated", "type": "bool", "name": "Activated"}, True) -        self.readConfig() +        pass      def isActivated(self):          return self.config["activated"] @@ -60,9 +50,6 @@ class Hook():          pass      def packageFinished(self, pypack): -        """ -            not implemented! -        """          pass      def beforeReconnecting(self, ip): diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 51cd78f2d..e8df540a8 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -18,7 +18,6 @@  """  import logging -import re  from os.path import exists  from os.path import join @@ -89,8 +88,14 @@ class Plugin(object):          self.pyfile = pyfile          self.thread = None # holds thread in future +	self.setup() +	      def __call__(self):  	return self.__name__ +     +    def setup(self): +	""" more init stuff if needed """ +	pass      def preprocessing(self, thread):          """ handles important things to do before starting """ @@ -98,6 +103,8 @@ class Plugin(object):  	if not self.account:  	    self.req.clearCookies() +	     +	self.pyfile.setStatus("starting")          return self.process(self.pyfile) @@ -178,6 +185,9 @@ class Plugin(object):      def download(self, url, get={}, post={}, ref=True, cookies=True):          """ downloads the url content to disk """ +	 +	self.pyfile.setStatus("downloading") +	          download_folder = self.config['general']['download_folder']  	location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) @@ -187,5 +197,7 @@ class Plugin(object):  	newname = self.req.download(url, self.pyfile.name, location, get, post, ref, cookies) +	self.pyfile.size = self.req.dl_size +	          if newname:  	    self.pyfile.name = newname diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index db229c747..501a57737 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -22,7 +22,6 @@ import logging  import subprocess  import tempfile  import threading -from os import remove  import Image diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py index 1651b91ed..9321c658f 100644 --- a/module/plugins/container/LinkList.py +++ b/module/plugins/container/LinkList.py @@ -3,7 +3,6 @@  from module.plugins.Container import Container -from os import linesep  class LinkList(Container):      __name__ = "LinkList" diff --git a/module/plugins/crypter/CryptItCom.py b/module/plugins/crypter/CryptItCom.py index cc9af8dd6..4dff06b21 100644 --- a/module/plugins/crypter/CryptItCom.py +++ b/module/plugins/crypter/CryptItCom.py @@ -24,7 +24,7 @@ class CryptItCom(Crypter):      def file_exists(self):          html = self.load(self.parent.url) -        if r'<div class="folder">Was ist Crypt-It</div>' in html): +        if r'<div class="folder">Was ist Crypt-It</div>' in html:              return False          return True         diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index adb26eab0..536df64d5 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -18,7 +18,6 @@      @interface-version: 0.2  """ -import asyncore  import socket  import thread diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index dc536fa1f..83daa9257 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -22,7 +22,6 @@ from os.path import exists  from os.path import join
  from os.path import exists
  from os import makedirs
 -import re
  import sys
  from module.plugins.Hoster import Hoster
 diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 92bc93f24..db256c2ec 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -2,9 +2,7 @@  # -*- coding: utf-8 -*-
  import re
 -from time import time
  from module.plugins.Hoster import Hoster
 -from module.unescape import unescape
  class PornhostCom(Hoster):
      __name__ = "PornhostCom"
 diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index c5fda76ae..61c388fec 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -2,9 +2,7 @@  # -*- coding: utf-8 -*-
  import re
 -from time import time
  from module.plugins.Hoster import Hoster
 -from module.unescape import unescape
  class PornhubCom(Hoster):
      __name__ = "PornhubCom"
 diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index 3d97e12d6..6cbd6416e 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -2,7 +2,6 @@  # -*- coding: utf-8 -*-
  import re
 -from time import time
  from module.plugins.Hoster import Hoster
  from module.unescape import unescape
 diff --git a/module/plugins/hoster/YourFilesTo.py b/module/plugins/hoster/YourFilesTo.py index 714e37bb2..04941f759 100644 --- a/module/plugins/hoster/YourFilesTo.py +++ b/module/plugins/hoster/YourFilesTo.py @@ -4,7 +4,6 @@  import re  import urllib  from module.plugins.Hoster import Hoster -from module.unescape import unescape  from time import time  class YourfilesTo(Hoster): diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 978d89a37..e40b0c9ad 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -9,71 +9,40 @@ class YoutubeCom(Hoster):      __type__ = "hoster"      __pattern__ = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*"      __version__ = "0.2" -    __config__ = [ ("int", "quality" , "Quality Setting", "hd;lq"), -                   ("int", "config", "Config Settings" , "default" ) ] +    __config__ = [ ("quality", "str" , "Quality Setting", "hd") ]      __description__ = """Youtube.com Video Download Hoster"""      __author_name__ = ("spoob")      __author_mail__ = ("spoob@pyload.org") - -    def __init__(self, parent): -        Hoster.__init__(self, parent) -        self.parent = parent -        self.html = None -        self.read_config() -        self.hd_available = False - -    def download_html(self): -        url = self.parent.url -        self.html = self.load(url) - -    def get_file_url(self): -        """ returns the absolute downloadable filepath -        """ -        if self.html == None: -            self.download_html() - -        videoId = self.parent.url.split("v=")[1].split("&")[0] -        videoHash = re.search(r'&t=(.+?)&', self.html).group(1) -        quality = "" -        if self.config['quality'] == "sd": -            quality = "&fmt=6" -        elif self.config['quality'] == "hd" and self.hd_available: -            quality = "&fmt=22" -        else: -            quality = "&fmt=18" -        file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality -        return file_url -    def verify_config(self): -        q = self.get_config("quality") -        if not (q == "hq" or q == "hd" or q == "sd"): -            self.config["quality"] = "hd" -        hq = self.get_config("high_quality") -        if hq: -            self.remove_config("high_quality") -        self.set_config() - -    def get_file_name(self): -        if self.html == None: -            self.download_html() +    def process(self, pyfile): +        html = self.load(pyfile.url) +                         +        if re.search(r"(.*eine fehlerhafte Video-ID\.)", html) != None: +            self.offline() +         +        videoId = pyfile.url.split("v=")[1].split("&")[0] +        videoHash = re.search(r'&t=(.+?)&', html).group(1) +         +                  file_name_pattern = '<meta name="title" content="(.+?)">'          is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)"          file_suffix = ".flv" -        is_hd = re.search(is_hd_pattern, self.html).group(1) -        self.hd_available = (is_hd == "true") -        if self.config['quality'] == "hd" or self.config['quality'] == "hq": +        is_hd = re.search(is_hd_pattern, html).group(1) +        hd_available = (is_hd == "true") +         +        if self.getConf("quality") == "hd" or self.getConf("quality") == "hq":              file_suffix = ".mp4" -        name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix +        name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix -        name = name.replace("&", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue") -        return name +        pyfile.name = name.replace("&", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")         -    def file_exists(self): -        """ returns True or False -        """ -        if self.html == None: -            self.download_html() -        if re.search(r"(.*eine fehlerhafte Video-ID\.)", self.html) != None: -            return False +        if self.getConf("quality") == "sd": +            quality = "&fmt=6" +        elif self.getConf("quality") == "hd" and hd_available: +            quality = "&fmt=22"          else: -            return True +            quality = "&fmt=18" +             +        file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality + "&asv=2" + +        self.download(file_url)
\ No newline at end of file diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 5e4d4710b..558d35415 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -11,6 +11,8 @@ from django.utils import simplejson  from django.utils.translation import ugettext as _  import base64 +from traceback import print_exc +  def format_time(seconds):      seconds = int(seconds) @@ -85,7 +87,8 @@ def remove_link(request, id):      try:          settings.PYLOAD.del_links([int(id)])          return JsonResponse("sucess") -    except: +    except Exception, e: +        print_exc()          return HttpResponseServerError()  @permission('pyload.can_see_dl')     diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html index d149853d5..71285ddb8 100644 --- a/module/web/templates/default/queue.html +++ b/module/web/templates/default/queue.html @@ -113,7 +113,7 @@ document.addEvent("domready", function(){          </span>
          <span style="font-size: 15px">{{ child.name }}</span><br />
      <div class="child_secrow">
 -        <span class="child_status">{{ child.status }}</span>{{child.error}} 
 +        <span class="child_status">{{ child.statusmsg }}</span>{{child.error}} 
          <span class="child_status">{{ child.size }} KB</span>
          <span class="child_status">{{ child.plugin }}</span>
          <span class="child_status">{% trans "Folder:" %} {{package.folder}}</span>
 diff --git a/pyLoadCli.py b/pyLoadCli.py index bbe126a3d..cecac282b 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -22,12 +22,7 @@ from getopt import getopt  import gettext  import os  import os.path -from os.path import abspath -from os.path import dirname  from os.path import join -from os.path import exists -from os.path import expanduser -from os import name as platform  import sys  from sys import exit  import threading @@ -112,7 +107,7 @@ class pyLoadCli:          return "%.2i:%.2i:%.2i" % (hours, minutes, seconds)      def format_size(self, size): -        return conv(size / 1024) + " MiB" +        return conv(size / 1024 ** 2) + " MiB"      def println(self, line, content):          print "\033[" + conv(line) + ";0H\033[2K" + conv(content) + "\033[" + conv((self.inputline if self.inputline > 0 else self.inputline + 1) - 1) + ";0H" @@ -135,7 +130,7 @@ class pyLoadCli:          line = 4          speed = 0          for download in data: -            if download["status"] == "downloading": +            if download["status"] == 12:  # downloading                  percent = download["percent"]                  z = percent / 4                  speed += download['speed'] diff --git a/pyLoadCore.py b/pyLoadCore.py index 5dbef139a..2b82f9008 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -22,51 +22,37 @@  """  CURRENT_VERSION = '0.4.0b' -from copy import deepcopy  from getopt import GetoptError  from getopt import getopt  import gettext -from glob import glob  from imp import find_module  import logging  import logging.handlers -from operator import attrgetter  from os import _exit -from os import chdir  from os import getcwd  from os import execv  from os import makedirs  from os import name as platform  from os import remove  from os import sep -from os.path import abspath -from os.path import basename -from os.path import dirname  from os.path import exists -from os.path import isabs  from os.path import join -from os.path import expanduser -from re import sub  import signal  import subprocess  import sys  from sys import argv  from sys import executable  from sys import exit -from sys import path  from sys import stdout -from sys import version_info  from tempfile import NamedTemporaryFile  import thread  import time  from time import sleep  from xmlrpclib import Binary -import __builtin__  from module import InitHomeDir  from module.ConfigParser import ConfigParser -from module.network.Request import getURL  import module.remote.SecureXMLRPCServer as Server  from module.web.ServerThread import WebServer @@ -240,6 +226,7 @@ class Core(object):          self.hookManager.coreReady()          while True: +                                      sleep(2)              if self.do_restart:                  self.log.info(_("restarting pyLoad")) @@ -249,6 +236,7 @@ class Core(object):                  self.log.info(_("pyLoad quits"))                  exit() +                              self.threadManager.work()              self.hookManager.periodical() @@ -357,8 +345,6 @@ class Core(object):          elif start < now and end < now and start > end: return True          else: return False -    def getMaxSpeed(self): -        return self.downloadSpeedLimit      def shutdown(self):          self.log.info(_("shutting down...")) @@ -366,13 +352,13 @@ class Core(object):              if self.config['webinterface']['activated']:                  self.webserver.quit()                  #self.webserver.join() -            for thread in self.thread_list.threads: -                thread.shutdown = True -            self.thread_list.stopAllDownloads() -            for thread in self.thread_list.threads: -                thread.join(10) -            self.file_list.save() -            self.requestFactory.clean() +            for thread in self.threadManager.threads: +                thread.put("quit") +            for pyfile in self.files.cache: +                pyfile.abortDownload() +             +            self.files.save() +#            self.requestFactory.clean()          except:              self.log.info(_("error while shutting down")) @@ -407,15 +393,17 @@ class ServerMethods():          for pyfile in [x.active for x in self.core.threadManager.threads + self.core.threadManager.localThreads if x.active]:              download = {}              download['id'] = pyfile.id -            download['name'] = pyfile.status.filename -            download['speed'] = pyfile.status.get_speed() -            download['eta'] = pyfile.status.get_ETA() -            download['kbleft'] = pyfile.status.kB_left() -            download['size'] = pyfile.status.size() -            download['percent'] = pyfile.status.percent() -            download['status'] = pyfile.status.type -            download['wait_until'] = pyfile.status.waituntil -            download['package'] = pyfile.package.data["package_name"] +            download['name'] = pyfile.name +            download['speed'] = pyfile.getSpeed() +            download['eta'] = pyfile.getETA() +            download['kbleft'] = pyfile.getKbLeft() +            download['size'] = pyfile.getSize() +            download['percent'] = pyfile.getPercent() +            download['status'] = pyfile.status +            download['statusmsg'] = pyfile.m.statusMsg[pyfile.status]  +            download['wait'] = pyfile.formatWait() +            download['wait_until'] = pyfile.waitUntil +            download['package'] = pyfile.package().name              downloads.append(download)          return downloads @@ -458,7 +446,7 @@ class ServerMethods():          status['speed'] = 0          for pyfile in [x.active for x in self.core.threadManager.threads if x.active]: -            status['speed'] += pyfile.status.getSpeed() +            status['speed'] += pyfile.getSpeed()          status['download'] = not self.core.threadManager.pause and self.is_time_download()          status['reconnect'] = self.core.config['reconnect']['activated'] and self.is_time_reconnect() @@ -487,8 +475,7 @@ class ServerMethods():      def del_links(self, ids):          for id in ids: -            #@TODO rewrite -            pass +            self.core.files.deleteLink(id)          self.core.files.save() | 
