Skip to content

Commit

Permalink
v5.22 完善更新
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYX committed Aug 27, 2023
1 parent c86fce0 commit 7a2e7b1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ def download_file(url, save_path):
response = requests.get(url, stream=True)
total_size = int(response.headers.get('content-length', 0))
size = 0
size_ls = []
tm_ls = []
tm = time.time()
size_ls = [0]
tm_ls = [tm]
cnt_ls = [0 for _ in range(5)]

with open(save_path, 'wb') as file:
for data in response.iter_content(chunk_size=1024):
size += file.write(data)
size_ls.append(size)
tm_ls.append(time.time())
progress_bar["value"]=size/total_size*100
if len(size_ls)>5:
operation_label.config(text="下载中... {:.0f}%\t-KB/s".format(progress_bar["value"]))
else:
operation_label.config(text="下载中... {:.0f}%\t{:.0f}KB/s".format(progress_bar["value"],(size-size_ls[-5])/(time.time()-tm_ls[-5])))
if time.time()>tm+1:
tm = time.time()
cnt_ls.append(len(tm_ls))
if cnt_ls[-1] == len(tm_ls):
operation_label.config(text="下载中... {:.0f}%\t{:.0f}KB/s".format(progress_bar["value"],(size-size_ls[cnt_ls[-5]])/(time.time()-tm_ls[cnt_ls[-5]])/1024))
progress_bar.update()

operation_label.config(text="下载完成,解压中...")
Expand Down

0 comments on commit 7a2e7b1

Please sign in to comment.