~ubuntu-branches/ubuntu/vivid/gpodder/vivid-proposed

« back to all changes in this revision

Viewing changes to src/gpodder/download.py

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2010-12-05 17:08:02 UTC
  • mfrom: (5.3.2 experimental) (5.2.10 sid)
  • Revision ID: james.westby@ubuntu.com-20101205170802-qbsq7r331j21np1i
Tags: 2.10-1
* New upstream release
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
588
588
        self.__limit_rate_value = self._config.limit_rate_value
589
589
        self.__limit_rate = self._config.limit_rate
590
590
 
 
591
        # Callbacks
 
592
        self._progress_updated = lambda x: None
 
593
 
591
594
        # If the tempname already exists, set progress accordingly
592
595
        if os.path.exists(self.tempname):
593
596
            try:
601
604
            # files for resuming when the file is queued
602
605
            open(self.tempname, 'w').close()
603
606
 
 
607
    def add_progress_callback(self, callback):
 
608
        self._progress_updated = callback
 
609
 
604
610
    def status_updated(self, count, blockSize, totalSize):
605
611
        # We see a different "total size" while downloading,
606
612
        # so correct the total size variable in the thread
609
615
 
610
616
        if self.total_size > 0:
611
617
            self.progress = max(0.0, min(1.0, float(count*blockSize)/self.total_size))
 
618
            self._progress_updated(self.progress)
612
619
 
613
620
        self.calculate_speed(count, blockSize)
614
621
 
763
770
                self.total_size = util.calculate_size(self.filename)
764
771
                log('Total size updated to %d', self.total_size, sender=self)
765
772
            self.progress = 1.0
 
773
            if gpodder.user_hooks is not None:
 
774
                gpodder.user_hooks.on_episode_downloaded(self.__episode)
766
775
            return True
767
776
        
768
777
        self.speed = 0.0