当前位置:网站首页>ftplib+ tqdm upload and download progress bar

ftplib+ tqdm upload and download progress bar

2022-08-09 13:43:00 Hong Dayu

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_)
原网站

版权声明
本文为[Hong Dayu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091236552702.html