当前位置:网站首页>ftplib+ tqdm 上传下载进度条

ftplib+ tqdm 上传下载进度条

2022-08-09 12:37:00 洪大宇

from fileinput import filename
import tqdm
import ftplib

server = "192.168.119.100"
port = 2121

ftp = ftplib.FTP()

#ftp.set_debuglevel(2)
ftp.connect(server,port)
ftp.login()

pwd = ftp.pwd()
ftp.cwd("xilinx")

filename="u-boot-xlnx-xilinx-v2021.2.zip"

size = ftp.size(filename)/1024

from tqdm import tqdm
import time

#fd = open(filename,"wb")

# with tqdm(total=size,desc='Download {}'.format(filename)) as pbar:
# def call_(data):
# l = len(data)/1024
# pbar.update(l)
# fd.write(data)
# ftp.retrbinary("RETR {}".format(filename),call_)

import os
filename="u-boot-xlnx-xilinx-v2021.2-debug.zip"
size = os.path.getsize(filename)/1024
fp = open(filename,"rb")

with tqdm(total=size,desc='Download {}'.format(filename)) as pbar:
    def call_(data):
        l = len(data)/1024
        pbar.update(l)
    ftp.storbinary("STOR {}".format(filename),fp,callback=call_)
原网站

版权声明
本文为[洪大宇]所创,转载请带上原文链接,感谢
https://hongdayu.blog.csdn.net/article/details/125528263