Commit 243da606 authored by Sandro Tosi's avatar Sandro Tosi

add a progressbar to sftp uploader

parent 75b10306
......@@ -27,6 +27,8 @@ import os
import pwd
import os.path
from binascii import hexlify
import progressbar
import functools
from dput.core import logger
from dput.uploader import AbstractUploader
......@@ -268,6 +270,10 @@ class SFTPUploader(AbstractUploader):
def progressbar(self, pbar, transferred, toBeTransferred):
pbar.maxval = toBeTransferred
def upload_file(self, filename, upload_filename=None):
See :meth:`dput.uploader.AbstractUploader.upload_file`
......@@ -280,7 +286,9 @@ class SFTPUploader(AbstractUploader):
logger.debug("Writing to: %s" % (upload_filename))
self._sftp.put(filename, upload_filename, **self.putargs)
self.pbar = progressbar.ProgressBar(widgets=[progressbar.Percentage()]).start()
self._sftp.put(filename, upload_filename, callback=functools.partial(self.progressbar, self.pbar), **self.putargs)
except IOError as e:
if e.errno == os.errno.EACCES:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment