예제 #1
0
    def do_transfer(self):
        """Performs the real transfer"""
        errors = dict()
        if pycp.options.global_pbar:
            num_files = len(self.transfer_info.to_transfer)
            total_size = self.transfer_info.size
            self.global_pbar = GlobalPbar(num_files, total_size)
            self.global_pbar.start()
        for (src, dest) in self.transfer_info.to_transfer:
            file_size = os.path.getsize(src)
            ftm = FileTransferManager(self, src, dest)
            self.on_new_transfer(src, dest, file_size)
            error = ftm.do_transfer()
            if error:
                errors[src] = error

        if pycp.options.move and not pycp.options.ignore_errors:
            for to_remove in self.transfer_info.to_remove:
                os.rmdir(to_remove)

        return errors
예제 #2
0
파일: transfer.py 프로젝트: aldrik/pycp
class TransferManager():
    """Handles transfer of a one or several sources to a destination

    One FileTransferManager object will be created for each file
    to transfer.

    """
    def __init__(self, sources, destination):
        self.sources = sources
        self.destination = destination
        self.transfer_info = TransferInfo(sources, destination)
        self.global_pbar = None
        self.file_pbar = None

    def do_transfer(self):
        """Performs the real transfer"""
        errors = dict()
        if pycp.options.global_pbar:
            num_files = len(self.transfer_info.to_transfer)
            total_size = self.transfer_info.size
            self.global_pbar = GlobalPbar(num_files, total_size)
            self.global_pbar.start()
        for (src, dest) in self.transfer_info.to_transfer:
            file_size = os.path.getsize(src)
            ftm = FileTransferManager(self, src, dest)
            self.on_new_transfer(src, dest, file_size)
            error = ftm.do_transfer()
            if error:
                errors[src] = error

        if pycp.options.move and not pycp.options.ignore_errors:
            for to_remove in self.transfer_info.to_remove:
                os.rmdir(to_remove)

        return errors

    def update(self, xferd):
        """Called during transfer of one file"""
        self.on_file_transfer(xferd)

    def on_new_transfer(self, src, dest, size):
        """If global pbar is false:
        create a new progress bar for just one file

        """
        if pycp.options.global_pbar:
            self.global_pbar.new_file(src, size)
        else:
            self.file_pbar = FilePbar(src, dest, size)
            self.file_pbar.start()

    def on_file_transfer(self, xferd):
        """If global pbar is False:
        update the file_pbar

        """
        if pycp.options.global_pbar:
            self.global_pbar.update(xferd)
        else:
            self.file_pbar.update(xferd)
예제 #3
0
class TransferManager():
    """Handles transfer of a one or several sources to a destination

    One FileTransferManager object will be created for each file
    to transfer.

    """
    def __init__(self, sources, destination):
        self.sources = sources
        self.destination = destination
        self.transfer_info = TransferInfo(sources, destination)
        self.global_pbar = None
        self.file_pbar = None

    def do_transfer(self):
        """Performs the real transfer"""
        errors = dict()
        if pycp.options.global_pbar:
            num_files = len(self.transfer_info.to_transfer)
            total_size = self.transfer_info.size
            self.global_pbar = GlobalPbar(num_files, total_size)
            self.global_pbar.start()
        for (src, dest) in self.transfer_info.to_transfer:
            file_size = os.path.getsize(src)
            ftm = FileTransferManager(self, src, dest)
            self.on_new_transfer(src, dest, file_size)
            error = ftm.do_transfer()
            if error:
                errors[src] = error

        if pycp.options.move and not pycp.options.ignore_errors:
            for to_remove in self.transfer_info.to_remove:
                os.rmdir(to_remove)

        return errors

    def update(self, xferd):
        """Called during transfer of one file"""
        self.on_file_transfer(xferd)

    def on_new_transfer(self, src, dest, size):
        """If global pbar is false:
        create a new progress bar for just one file

        """
        if pycp.options.global_pbar:
            self.global_pbar.new_file(src, size)
        else:
            self.file_pbar = FilePbar(src, dest, size)
            self.file_pbar.start()

    def on_file_transfer(self, xferd):
        """If global pbar is False:
        update the file_pbar

        """
        if pycp.options.global_pbar:
            self.global_pbar.update(xferd)
        else:
            self.file_pbar.update(xferd)
예제 #4
0
파일: transfer.py 프로젝트: aldrik/pycp
    def do_transfer(self):
        """Performs the real transfer"""
        errors = dict()
        if pycp.options.global_pbar:
            num_files = len(self.transfer_info.to_transfer)
            total_size = self.transfer_info.size
            self.global_pbar = GlobalPbar(num_files, total_size)
            self.global_pbar.start()
        for (src, dest) in self.transfer_info.to_transfer:
            file_size = os.path.getsize(src)
            ftm = FileTransferManager(self, src, dest)
            self.on_new_transfer(src, dest, file_size)
            error = ftm.do_transfer()
            if error:
                errors[src] = error

        if pycp.options.move and not pycp.options.ignore_errors:
            for to_remove in self.transfer_info.to_remove:
                os.rmdir(to_remove)

        return errors