Esempio n. 1
0
	def update(self, pbar):
		speed = 0

		if pbar.seconds_elapsed >= 1 and pbar.value_cur > 0:
			speed = pbar.value_cur / pbar.seconds_elapsed

		return util.format_speed(speed)
Esempio n. 2
0
    def update(self, pbar):
        speed = 0

        if pbar.seconds_elapsed >= 1 and pbar.value_cur > 0:
            speed = pbar.value_cur / pbar.seconds_elapsed

        return util.format_speed(speed)
Esempio n. 3
0
	def download(self, logger=None):
		if logger is None:
			logger = logging.getLogger("pakfire")

		downloads = self.get_downloads()

		# If there are no downloads, we can just stop here.
		if not downloads:
			return

		# Get free space of the download location.
		path = os.path.realpath(REPO_CACHE_DIR)
		while not os.path.ismount(path):
			path = os.path.dirname(path)
		path_stat = os.statvfs(path)

		if self.download_size >= path_stat.f_bavail * path_stat.f_bsize:
			raise DownloadError, _("Not enough space to download %s of packages.") \
				% util.format_size(self.download_size)

		logger.info(_("Downloading packages:"))
		time_start = time.time()

		counter = 0
		counter_downloads = len(downloads)
		for step in downloads:
			counter += 1

			# Download the package file.
			step.binary_pkg = step.pkg.download(
				text="(%d/%d): " % (counter, counter_downloads),
				logger=logger)

		# Write an empty line to the console when there have been any downloads.
		width, height = util.terminal_size()

		# Print a nice line.
		logger.info("-" * width)

		# Format and calculate download information.
		time_stop = time.time()
		download_time = time_stop - time_start
		download_speed = self.download_size / download_time
		download_speed = util.format_speed(download_speed)
		download_size = util.format_size(self.download_size)
		download_time = util.format_time(download_time)

		line = "%s | %5sB     %s     " % \
			(download_speed, self.download_size, download_time)
		line = " " * (width - len(line)) + line
		logger.info(line)
		logger.info("")
Esempio n. 4
0
    def download(self, logger=None):
        if logger is None:
            logger = logging.getLogger("pakfire")

        downloads = self.get_downloads()

        # If there are no downloads, we can just stop here.
        if not downloads:
            return

        # Get free space of the download location.
        path = os.path.realpath(REPO_CACHE_DIR)
        while not os.path.ismount(path):
            path = os.path.dirname(path)
        path_stat = os.statvfs(path)

        if self.download_size >= path_stat.f_bavail * path_stat.f_bsize:
            raise DownloadError, _("Not enough space to download %s of packages.") \
             % util.format_size(self.download_size)

        logger.info(_("Downloading packages:"))
        time_start = time.time()

        counter = 0
        counter_downloads = len(downloads)
        for step in downloads:
            counter += 1

            # Download the package file.
            step.binary_pkg = step.pkg.download(text="(%d/%d): " %
                                                (counter, counter_downloads),
                                                logger=logger)

        # Write an empty line to the console when there have been any downloads.
        width, height = util.terminal_size()

        # Print a nice line.
        logger.info("-" * width)

        # Format and calculate download information.
        time_stop = time.time()
        download_time = time_stop - time_start
        download_speed = self.download_size / download_time
        download_speed = util.format_speed(download_speed)
        download_size = util.format_size(self.download_size)
        download_time = util.format_time(download_time)

        line = "%s | %5sB     %s     " % \
         (download_speed, self.download_size, download_time)
        line = " " * (width - len(line)) + line
        logger.info(line)
        logger.info("")