diff options
| -rw-r--r-- | module/FileDatabase.py | 43 | ||||
| -rwxr-xr-x | module/network/Request.py | 18 | ||||
| -rw-r--r-- | module/web/ajax/views.py | 4 | ||||
| -rw-r--r-- | module/web/media/default/img/status_failed.png | bin | 700 -> 701 bytes | |||
| -rw-r--r-- | module/web/media/default/img/status_offline.png (renamed from module/web/media/default/img/status_aborted.png) | bin | 700 -> 700 bytes | |||
| -rw-r--r-- | module/web/media/default/img/status_proc.png | bin | 0 -> 512 bytes | |||
| -rw-r--r-- | module/web/media/default/img/status_queue.png | bin | 0 -> 7613 bytes | |||
| -rw-r--r-- | module/web/pyload/views.py | 34 | ||||
| -rw-r--r-- | module/web/templates/default/collector.html | 4 | ||||
| -rw-r--r-- | module/web/templates/default/home.html | 4 | ||||
| -rw-r--r-- | module/web/templates/default/queue.html | 4 | ||||
| -rwxr-xr-x | pyLoadCli.py | 2 | ||||
| -rwxr-xr-x | pyLoadCore.py | 7 | 
13 files changed, 94 insertions, 26 deletions
| diff --git a/module/FileDatabase.py b/module/FileDatabase.py index b24467612..7e8d043d2 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -40,6 +40,18 @@ statusMap = {      "processing":  13  } +def formatSize(size): +	"""formats size of bytes""" +	size = int(size) +	steps = 0 +	sizes = ["B", "KB", "MB", "GB" , "TB"] +	 +	while size > 1000: +		size /= 1024.0 +		steps += 1 +	 +	return "%.2f %s" % (size, sizes[steps]) +  ########################################################################  class FileHandler:  	"""Handles all request made to obtain information,  @@ -411,6 +423,7 @@ class FileDatabaseBackend(Thread):  				'url': r[1],  				'name': r[2],  				'size': r[3], +			    'format_size': formatSize(r[3]),  				'status': r[4],  			    'statusmsg': self.manager.statusMsg[r[4]],  				'error': r[5], @@ -465,6 +478,7 @@ class FileDatabaseBackend(Thread):  				'url': r[1],  				'name': r[2],  				'size': r[3], +			    'format_size': formatSize(r[3]),  				'status': r[4],  			    'statusmsg': self.manager.statusMsg[r[4]],  				'error': r[5], @@ -614,6 +628,7 @@ class PyFile():  				'name': self.name,  		        'plugin' : self.pluginname,  				'size': self.getSize(), +		        'format_size': self.formatSize(),  				'status': self.status,  		        'statusmsg': self.m.statusMsg[self.status],  				'package': self.packageid, @@ -643,8 +658,28 @@ class PyFile():  	def formatWait(self):  		""" formats and return wait time in humanreadable format """ -		return self.waitUntil - time() +		seconds = self.waitUntil - time() +		 +		if seconds < 0 : return "00:00:00" +				 +		hours, seconds = divmod(seconds, 3600) +		minutes, seconds = divmod(seconds, 60) +		return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) +	def formatSize(self): +		""" formats size to readable format """ +		return formatSize(self.getSize()) + +	def formatETA(self): +		""" formats eta to readable format """ +		seconds = self.getETA() +		 +		if seconds < 0 : return "00:00:00" +				 +		hours, seconds = divmod(seconds, 3600) +		minutes, seconds = divmod(seconds, 60) +		return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) +		  	def getSpeed(self):  		""" calculates speed """  		try: @@ -659,10 +694,10 @@ class PyFile():  		except:  			return 0 -	def getKbLeft(self): -		""" gets kb left """ +	def getBytesLeft(self): +		""" gets bytes left """  		try: -			return self.plugin.req.kB_left() +			return self.plugin.req.bytes_left()  		except:  			return 0 diff --git a/module/network/Request.py b/module/network/Request.py index 012d01ddf..d1964d87f 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -85,7 +85,7 @@ class Request:          self.pycurl.setopt(pycurl.CONNECTTIMEOUT, 30)          self.pycurl.setopt(pycurl.NOSIGNAL, 1)          self.pycurl.setopt(pycurl.NOPROGRESS, 0) -        self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.noprogress) +        self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.progress)          self.pycurl.setopt(pycurl.AUTOREFERER, 1)          self.pycurl.setopt(pycurl.HEADERFUNCTION, self.write_header)          self.pycurl.setopt(pycurl.BUFFERSIZE, self.bufferSize) @@ -124,7 +124,8 @@ class Request:          return None      def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, no_post_encode=False): - +         +        self.pycurl.setopt(pycurl.NOPROGRESS, 1)          url = str(url) @@ -154,7 +155,6 @@ class Request:              self.pycurl.setopt(pycurl.REFERER, self.lastURL)          if just_header: -            self.pycurl.setopt(pycurl.NOPROGRESS, 1)              self.pycurl.setopt(pycurl.NOBODY, 1)              self.pycurl.perform()              self.lastEffectiveURL = self.pycurl.getinfo(pycurl.EFFECTIVE_URL) @@ -198,8 +198,8 @@ class Request:      def download(self, url, file_name, folder, get={}, post={}, ref=True, cookies=True, no_post_encode=False):          url = str(url) - -        self.pycurl.setopt(pycurl.PROGRESSFUNCTION, self.progress) +         +        self.pycurl.setopt(pycurl.NOPROGRESS, 0)          if post:              if not no_post_encode: @@ -346,18 +346,14 @@ class Request:          except:              return 0 -    def kB_left(self): -        return (self.dl_size - self.dl_arrived) / 1024 +    def bytes_left(self): +        return (self.dl_size - self.dl_arrived)      def progress(self, dl_t, dl_d, up_t, up_d):          if self.abort:              return False          self.dl_arrived = int(dl_d)          self.dl_size = int(dl_t) -     -    def noprogress(self, dl_t, dl_d, up_t, up_d): -        if self.abort: -            return False      def get_free_name(self, folder, file_name):          file_count = 0 diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 2c807f6c9..b1fe2f676 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -108,12 +108,12 @@ def links(request):              ids.append(link['id'])              if link['status'] == 12: -                link['info'] = "%s @ %s kb/s" % (format_time(link['eta']), round(link['speed'], 2)) +                link['info'] = "%s @ %s kb/s" % (link['format_eta'], round(link['speed'], 2))              elif link['status'] == 5:                  link['percent'] = 0                  link['size'] = 0                  link['kbleft'] = 0 -                link['info'] = _("waiting %s") % format_time(link['wait_until'] - time.time()) +                link['info'] = _("waiting %s") % link['format_wait']              else:                  link['info'] = "" diff --git a/module/web/media/default/img/status_failed.png b/module/web/media/default/img/status_failed.pngBinary files differ index 0cfd58596..c37bd062e 100644 --- a/module/web/media/default/img/status_failed.png +++ b/module/web/media/default/img/status_failed.png diff --git a/module/web/media/default/img/status_aborted.png b/module/web/media/default/img/status_offline.pngBinary files differ index 0cfd58596..0cfd58596 100644 --- a/module/web/media/default/img/status_aborted.png +++ b/module/web/media/default/img/status_offline.png diff --git a/module/web/media/default/img/status_proc.png b/module/web/media/default/img/status_proc.pngBinary files differ new file mode 100644 index 000000000..67de2c6cc --- /dev/null +++ b/module/web/media/default/img/status_proc.png diff --git a/module/web/media/default/img/status_queue.png b/module/web/media/default/img/status_queue.pngBinary files differ new file mode 100644 index 000000000..293b13f77 --- /dev/null +++ b/module/web/media/default/img/status_queue.png diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index d75b7a485..b93ed603e 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -81,6 +81,23 @@ def home(request):  @check_server  def queue(request):      queue = settings.PYLOAD.get_queue() +    for package in queue.itervalues(): +        for pyfile in package["links"].itervalues(): +            if pyfile["status"] == 0: +                pyfile["icon"] = "status_finished.png" +            elif pyfile["status"] in (2,3): +                pyfile["icon"] = "status_queue.png" +            elif pyfile["status"] in (9,1): +                pyfile["icon"] = "status_offline.png" +            elif pyfile["status"] == 5: +                pyfile["icon"] = "status_waiting.png" +            elif pyfile["status"] == 8: +                pyfile["icon"] = "status_failed.png" +            elif pyfile["status"] in (11,13): +                pyfile["icon"] = "status_proc.png" +            else: +                pyfile["icon"] = "status_downloading.png" +                  return render_to_response(join(settings.TEMPLATE, 'queue.html'), RequestContext(request, {'content': queue}, [status_proc])) @@ -172,6 +189,23 @@ def logs(request, page=0):  @check_server  def collector(request):      queue = settings.PYLOAD.get_collector() +    for package in queue.itervalues(): +        for pyfile in package["links"].itervalues(): +            if pyfile["status"] == 0: +                pyfile["icon"] = "status_finished.png" +            elif pyfile["status"] in (2,3): +                pyfile["icon"] = "status_queue.png" +            elif pyfile["status"] in (9,1): +                pyfile["icon"] = "status_offline.png" +            elif pyfile["status"] == 5: +                pyfile["icon"] = "status_waiting.png" +            elif pyfile["status"] == 8: +                pyfile["icon"] = "status_failed.png" +            elif pyfile["status"] in (11,13): +                pyfile["icon"] = "status_proc.png" +            else: +                pyfile["icon"] = "status_downloading.png" +          return render_to_response(join(settings.TEMPLATE, 'collector.html'), RequestContext(request, {'content': queue}, [status_proc])) diff --git a/module/web/templates/default/collector.html b/module/web/templates/default/collector.html index b0d5b1839..09725103b 100644 --- a/module/web/templates/default/collector.html +++ b/module/web/templates/default/collector.html @@ -121,12 +121,12 @@ document.addEvent("domready", function(){      {% for lid, child in package.links.iteritems %}
      <div class="child" id="file_{{lid}}">
          <span class="child_status">
 -            <img src="/media/default/img/status_{{child.status_type}}.png" style="width: 12px; height:12px;"/>
 +            <img src="/media/default/img/{{child.icon}}" style="width: 12px; height:12px;"/>
          </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.size }} KB</span>
 +        <span class="child_status">{{ child.format_size }}/span>
          <span class="child_status">{{ child.plugin }}</span>
          <span class="child_status">{% trans "Folder:" %} {{child.folder}}</span>
            
 diff --git a/module/web/templates/default/home.html b/module/web/templates/default/home.html index 76f87b203..b4602f021 100644 --- a/module/web/templates/default/home.html +++ b/module/web/templates/default/home.html @@ -171,7 +171,7 @@ var LinkEntry = new Class({                  this.elements.name.set('text', item.name);
                  this.elements.status.set('text', item.statusmsg);
                  this.elements.info.set('text', item.info);
 -                this.elements.kbleft.set('text', HumanFileSize(item.size / (1024)));
 +                this.elements.kbleft.set('text', item.format_size);
                  this.elements.percent.set('text', item.percent+ '% / '+ HumanFileSize((item.size-item.kbleft) / (1024)));
                  this.bar.start({
                      'width': item.percent,
 @@ -210,7 +210,7 @@ var LinkEntry = new Class({      <td id="link_{{ link.id }}_name">{{ link.name }}</td>
      <td id="link_{{ link.id }}_status">{{ link.status }}</td>
      <td id="link_{{ link.id }}_info">{{ link.info }}</td>
 -    <td id="link_{{ link.id }}_kbleft">{{ link.size }}</td>
 +    <td id="link_{{ link.id }}_kbleft">{{ link.format_size }}</td>
      <td>
          <font id="link_{{ link.id }}_percent">{{ link.percent }}% /{{ link.kbleft }}</font>
          <img id="link_{{ link.id }}_remove" style="vertical-align: middle; margin-right: -20px; margin-left: 5px; margin-top: -2px; cursor:pointer;" src="media/default/img/control_cancel.png"/>
 diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html index 71285ddb8..2ca25e03d 100644 --- a/module/web/templates/default/queue.html +++ b/module/web/templates/default/queue.html @@ -109,12 +109,12 @@ document.addEvent("domready", function(){      {% for lid, child in package.links.iteritems %}
      <div class="child" id="file_{{lid}}">
          <span class="child_status">
 -            <img src="/media/default/img/status_{{child.status}}.png" style="width: 12px; height:12px;"/>
 +            <img src="/media/default/img/{{child.icon}}" style="width: 12px; height:12px;"/>
          </span>
          <span style="font-size: 15px">{{ child.name }}</span><br />
      <div class="child_secrow">
          <span class="child_status">{{ child.statusmsg }}</span>{{child.error}} 
 -        <span class="child_status">{{ child.size }} KB</span>
 +        <span class="child_status">{{ child.format_size }}</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 8aee9d8c7..b08a56f28 100755 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -136,7 +136,7 @@ class pyLoadCli:                  speed += download['speed']                  self.println(line, cyan(download["name"]))                  line += 1 -                self.println(line, blue("[") + yellow(z * "#" + (25-z) * " ") + blue("] ") + green(conv(percent) + "%") + _(" Speed: ") + green(conv(int(download['speed'])) + " kb/s") + _(" Size: ") + green(self.format_size(download['size'])) + _(" Finished in: ") + green(self.format_time(download['eta']))  + _(" ID: ") + green(conv(download['id']))) +                self.println(line, blue("[") + yellow(z * "#" + (25-z) * " ") + blue("] ") + green(conv(percent) + "%") + _(" Speed: ") + green(conv(int(download['speed'])) + " kb/s") + _(" Size: ") + green(download['format_size']) + _(" Finished in: ") + green(download['format_eta'])  + _(" ID: ") + green(conv(download['id'])))                  line += 1              if download["status"] == "waiting":                  self.println(line, cyan(download["name"])) diff --git a/pyLoadCore.py b/pyLoadCore.py index bfc575b94..075d22a19 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -408,12 +408,15 @@ class ServerMethods():              download['name'] = pyfile.name              download['speed'] = pyfile.getSpeed()              download['eta'] = pyfile.getETA() -            download['kbleft'] = pyfile.getKbLeft() +            download['format_eta'] = pyfile.formatETA() +            download['kbleft'] = pyfile.getBytesLeft() #holded for backward comp. +            download['bleft'] = pyfile.getBytesLeft()              download['size'] = pyfile.getSize() +            download['format_size'] = pyfile.formatSize()              download['percent'] = pyfile.getPercent()              download['status'] = pyfile.status              download['statusmsg'] = pyfile.m.statusMsg[pyfile.status]  -            download['wait'] = pyfile.formatWait() +            download['format_wait'] = pyfile.formatWait()              download['wait_until'] = pyfile.waitUntil              download['package'] = pyfile.package().name              downloads.append(download) | 
