ymodem.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:device-updater 作者: spark 项目源码 文件源码
def transfer(self, file, channel:RawIOBase, progress:ProgressSpan):
        """
        Transfers a single file to the device and closes the session, so the device places the data in the
        target location.

        file: the file to transfer via ymodem
        channel: the ymodem endpoint
        progress: notification of progress
        """
        self.seq = 0
        self.channel = channel
        self.progress = progress

        file.seek(0, os.SEEK_END)
        size = file.tell()
        file.seek(0, os.SEEK_SET)
        progress.min = 0
        progress.max = size
        progress.update(0)

        response = self.send_filename_header(self.default_file_name, size)
        while response == LightYModemClient.ack:
            response = self.send_packet(file)
        file.close()
        if response != LightYModemClient.eot:
            raise LightYModemException("Unable to transfer the file to the device. Code=%d" % response)
        self._send_close()
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号