diff options
| author | 2010-07-29 20:08:07 +0200 | |
|---|---|---|
| committer | 2010-07-29 20:08:07 +0200 | |
| commit | ff21df6b2ccdaf5161351ab69086d358a98c241d (patch) | |
| tree | d958eeb0d78ee6eec38349ed2884bb33ae429e6f | |
| parent | more improvements and cleaned some imports (diff) | |
| download | pyload-ff21df6b2ccdaf5161351ab69086d358a98c241d.tar.xz | |
restart working and client information
| -rw-r--r-- | module/FileDatabase.py | 62 | ||||
| -rw-r--r-- | module/PluginThread.py | 14 | ||||
| -rw-r--r-- | module/plugins/Container.py | 18 | ||||
| -rw-r--r-- | module/plugins/Crypter.py | 10 | ||||
| -rw-r--r-- | module/plugins/container/LinkList.py | 5 | ||||
| -rw-r--r-- | module/web/ajax/views.py | 10 | ||||
| -rw-r--r-- | module/web/pyload/views.py | 8 | ||||
| -rw-r--r-- | module/web/templates/default/home.html | 6 | ||||
| -rwxr-xr-x | pyLoadCore.py | 19 | 
9 files changed, 98 insertions, 54 deletions
| diff --git a/module/FileDatabase.py b/module/FileDatabase.py index 77f1fde9e..6cc8d10ff 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -118,9 +118,9 @@ class FileHandler:  	@change  	def deletePackage(self, id):  		"""delete package and all contained links""" - -		self.lock.acquire() +		self.lock.acquire() +  		if self.packageCache.has_key(id):  			del self.packageCache[id] @@ -199,20 +199,40 @@ class FileHandler:  		self.lock.acquire() +		#@TODO clean mess +		  		if self.jobCache.has_key(occ): -			pass +			if self.jobCache[occ]: +				id = self.jobCache[occ].pop() +				if id == "empty": +					pyfile = None +				else: +					pyfile = self.getFile(id) +			else: +				jobs = self.db.getJob(occ) +				jobs.reverse() +				if not jobs: +					self.jobCache[occ].append("empty") +					pyfile = None +				else: +					self.jobCache[occ].extend(jobs) +					pyfile = self.getFile(self.jobCache[occ].pop()) +				  		else:  			self.jobCache = {} #better not caching to much  			jobs = self.db.getJob(occ)  			jobs.reverse()  			self.jobCache[occ] = jobs -		 -			#@TODO: maybe the new job has to be approved... -		if not self.jobCache[occ]: -			pyfile = None -		else: +			if not jobs: +				self.jobCache[occ].append("empty") +				pyfile = None +		  			pyfile = self.getFile(self.jobCache[occ].pop()) +			#@TODO: maybe the new job has to be approved... +					 +		 +		#pyfile = self.getFile(self.jobCache[occ].pop())  		self.lock.release()  		return pyfile @@ -226,7 +246,23 @@ class FileHandler:  			self.filecount = self.db.filecount(1)  		return self.filecount - +	 +	#---------------------------------------------------------------------- +	def restartPackage(self, id): +		"""restart package""" +		if self.packageCache.has_key(id): +			pass +	 +	def restartFile(self, id): +		""" restart link""" +		if self.cache.has_key(id): +			self.cache[id].abortDownload() +			self.cache[id].status = 3 +			self.cache[id].name = self.cache[id].url +			self.cache[id].sync() +		else: +			self.db.restartFile(id) +		  ######################################################################### @@ -406,6 +442,14 @@ class FileDatabaseBackend(Thread):  		self.c.execute('UPDATE packages SET name=?,folder=?,site=?,password=?,queue=? WHERE id=?', (p.name, p.folder, p.site, p.password, p.queue, str(p.id)))  	@async +	def restartFile(self, id): +		self.c.execute('UPDATE links SET status=3 WHERE id=?', ( str(id), ) ) + +	@async +	def restartPackage(self, id): +		pass +		 +	@async  	def commit(self):  		self.conn.commit() diff --git a/module/PluginThread.py b/module/PluginThread.py index 313183cca..037fa0d4f 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -64,7 +64,7 @@ class DownloadThread(PluginThread):  			if self.active == "quit":  				return True -			self.m.log.info(_("starting %s" % pyfile.name)) +			self.m.log.info(_("Download starts: %s" % pyfile.name))  			try:  				pyfile.plugin.preprocessing(self) @@ -75,7 +75,7 @@ class DownloadThread(PluginThread):  				continue  			except Abort: -				self.m.log.info(_("%s aborted") % pyfile.name) +				self.m.log.info(_("Download aborted: %s") % pyfile.name)  				pyfile.setStatus("aborted")  				self.active = False  				pyfile.release() @@ -92,7 +92,7 @@ class DownloadThread(PluginThread):  			except Retry: -				self.m.log.info(_("restarting %s") % pyfile.name) +				self.m.log.info(_("Download restarted: %s") % pyfile.name)  				self.queue.put(pyfile)  				continue @@ -102,10 +102,10 @@ class DownloadThread(PluginThread):  				if msg == "offline":  					pyfile.setStatus("offline") -					self.m.log.warning(_("%s is offline.") % pyfile.name) +					self.m.log.warning(_("Download is offline: %s") % pyfile.name)  				else:  					pyfile.setStatus("failed") -					self.m.log.warning(_("%s failed: %s") % (pyfile.name, msg)) +					self.m.log.warning(_("Download failed: %s | %s") % (pyfile.name, msg))  					pyfile.error = msg  				continue @@ -117,7 +117,7 @@ class DownloadThread(PluginThread):  			except Exception, e:  				pyfile.setStatus("failed") -				self.m.log.error(_("%s failed: %s") % (pyfile.name, str(e))) +				self.m.log.error(_("Download failed: %s | %s") % (pyfile.name, str(e)))  				if self.m.core.debug:  					print_exc() @@ -129,7 +129,7 @@ class DownloadThread(PluginThread):  				self.m.core.files.save() -			self.m.log(_("%s finished") % pyfile.name) +			self.m.log.info(_("Download finished: %s") % pyfile.name)  			#@TODO hooks, packagaefinished etc diff --git a/module/plugins/Container.py b/module/plugins/Container.py index 794c52508..729dc11e1 100644 --- a/module/plugins/Container.py +++ b/module/plugins/Container.py @@ -17,9 +17,11 @@      @author: mkaay  """ -from module.plugins.Plugin import Plugin +### can be left blank and removed in future, no seperation of crypter and container needed atm. -class Container(Plugin): +from module.plugins.Crypter import Crypter + +class Container(Crypter):      __name__ = "Container"      __version__ = "0.1"      __pattern__ = None @@ -27,15 +29,3 @@ class Container(Plugin):      __description__ = """Base container plugin"""      __author_name__ = ("mkaay")      __author_mail__ = ("mkaay@mkaay.de") -     -    def decrypt(self): -        pass -     -    def createNewPackage(self): -        return False -     -    def getPackages(self): -        return [] -     -    def getLinks(self): -        return [] diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index 09558ad0b..e0459c714 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -27,3 +27,13 @@ class Crypter(Plugin):      __description__ = """Base crypter plugin"""      __author_name__ = ("mkaay")      __author_mail__ = ("mkaay@mkaay.de") + +    #---------------------------------------------------------------------- +    def createPackage(self, name, urls): +        """ create a new package """ +        pass +     +    def fillCurrentPackage(self, name, urls): +        """ rename current package and fill with urls""" +        pass +        
\ No newline at end of file diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py index 9321c658f..3ffeeb193 100644 --- a/module/plugins/container/LinkList.py +++ b/module/plugins/container/LinkList.py @@ -12,11 +12,6 @@ class LinkList(Container):      __author_name__ = ("spoob", "jeix")      __author_mail__ = ("spoob@pyload.org", "jeix@hasnomail.com") -    def __init__(self, parent): -        Container.__init__(self, parent) -        self.parent = parent -        self.html = None -        self.read_config()      def proceed(self, linkList, location):          txt = open(linkList, 'r') diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 558d35415..02c135bfe 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -107,10 +107,10 @@ def links(request):          ids = []          for link in links:              ids.append(link['id']) -            print link['status'] -            if link['status'] == 'downloading': + +            if link['status'] == 12:                  link['info'] = "%s @ %s kb/s" % (format_time(link['eta']), round(link['speed'], 2)) -            elif link['status'] == 'waiting': +            elif link['status'] == 5:                  link['percent'] = 0                  link['size'] = 0                  link['kbleft'] = 0 @@ -211,7 +211,7 @@ def restart_package(request, id):      try:          settings.PYLOAD.restart_package(int(id))          return JsonResponse("sucess") -    except: +    except Exception:          return HttpResponseServerError()  @permission('pyload.can_add_dl') @@ -219,7 +219,7 @@ def restart_link(request, id):      try:          settings.PYLOAD.restart_file(int(id))          return JsonResponse("sucess") -    except: +    except Exception:          return HttpResponseServerError()  @permission('pyload.can_add_dl') diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 52b58cd03..67ac6c07a 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -67,7 +67,13 @@ def base(request, messages):  @permission('pyload.can_see_dl')  @check_server  def home(request): -    return render_to_response(join(settings.TEMPLATE, 'home.html'), RequestContext(request, {'content': settings.PYLOAD.status_downloads()}, [status_proc])) +    res = settings.PYLOAD.status_downloads() + +    for link in res: +        if link["status"] == 12: +            link["information"] = "%s kB @ %s kB/s" %  (link["size"] - link["kbleft"], link["speed"]) +     +    return render_to_response(join(settings.TEMPLATE, 'home.html'), RequestContext(request, {'content': res}, [status_proc]))  @login_required diff --git a/module/web/templates/default/home.html b/module/web/templates/default/home.html index f3d40b4e0..76f87b203 100644 --- a/module/web/templates/default/home.html +++ b/module/web/templates/default/home.html @@ -169,10 +169,10 @@ var LinkEntry = new Class({          },
          update: function(item){
                  this.elements.name.set('text', item.name);
 -                this.elements.status.set('text', item.status);
 +                this.elements.status.set('text', item.statusmsg);
                  this.elements.info.set('text', item.info);
 -                this.elements.kbleft.set('text', HumanFileSize(item.size));
 -                this.elements.percent.set('text', item.percent+ '% / '+ HumanFileSize(item.size-item.kbleft));
 +                this.elements.kbleft.set('text', HumanFileSize(item.size / (1024)));
 +                this.elements.percent.set('text', item.percent+ '% / '+ HumanFileSize((item.size-item.kbleft) / (1024)));
                  this.bar.start({
                      'width': item.percent,
                      'background-color': [Math.round(120/100*item.percent),100,100].hsbToRgb().rgbToHex()
 diff --git a/pyLoadCore.py b/pyLoadCore.py index 2b82f9008..dd7eebcc9 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -156,8 +156,12 @@ class Core(object):          self.config = ConfigParser() +        translation = gettext.translation("pyLoad", self.path("locale"), languages=["en", self.config['general']['language']]) +        translation.install(unicode=(True if sys.getfilesystemencoding().lower().startswith("utf") else False)) +                  self.debug = self.doDebug or self.config['general']['debug_mode'] +        self.check_file(self.config['log']['log_folder'], _("folder for logs"), True)          if self.debug:              self.init_logger(logging.DEBUG) # logging level @@ -167,9 +171,6 @@ class Core(object):          self.do_kill = False          self.do_restart = False -        translation = gettext.translation("pyLoad", self.path("locale"), languages=["en", self.config['general']['language']]) -        translation.install(unicode=(True if sys.getfilesystemencoding().lower().startswith("utf") else False)) -                  self.log.info(_("Using home directory: %s") % getcwd() )          #@TODO refractor @@ -181,7 +182,6 @@ class Core(object):          self.check_install("tesseract", _("tesseract for captcha reading"), False)          self.check_install("gocr", _("gocr for captcha reading"), False) -        self.check_file(self.config['log']['log_folder'], _("folder for logs"), True)          self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True)          if self.config['ssl']['activated']: @@ -316,12 +316,13 @@ class Core(object):                      file_created = False          if not file_exists and not quiet:              if file_created: -                self.log.info( _("%s created") % description ) +                #self.log.info( _("%s created") % description ) +                pass              else:                  if not empty:                      self.log.warning( _("could not find %s: %s") % (description, tmp_name) )                  else: -                    self.log.warning( _("could not create %s: %s") % (description, tmp_name) ) +                    print _("could not create %s: %s") % (description, tmp_name)                  if essential:                      exit() @@ -508,12 +509,10 @@ class ServerMethods():          pass      def restart_package(self, packid): -        #@TODO package resett -        pass +        self.core.files.restartPackage(packid)      def restart_file(self, fileid): -        #@TODO file resett -        pass +        self.core.files.restartFile(fileid)      def upload_container(self, filename, type, content):          #@TODO py2.5 unproofed | 
