File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
backends/qualcomm/scripts Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,26 @@ def _download_qnn_sdk() -> Optional[pathlib.Path]:
5959 print (f"Downloading Qualcomm SDK from { qairt_url } ..." )
6060 try :
6161 # Use urlretrieve with a reporthook to show progress
62- def report_progress (block_num , block_size , total_size ):
63- downloaded = block_num * block_size
64- percent = downloaded / total_size * 100
65- print (
66- f"Downloaded: { downloaded } /{ total_size } bytes ({ percent :.2f} %)" ,
67- end = "\r " ,
68- )
62+ def make_report_progress ():
63+ last_reported = 0 # nonlocal variable
6964
65+ def report_progress (block_num , block_size , total_size ):
66+ nonlocal last_reported
67+ downloaded = block_num * block_size
68+ percent = downloaded / total_size * 100
69+
70+ # Report every 20%
71+ if percent - last_reported >= 20 or percent >= 100 :
72+ print (
73+ f"Downloaded: { downloaded } /{ total_size } bytes ({ percent :.2f} %)"
74+ )
75+ last_reported = percent
76+
77+ return report_progress
78+
79+ report_progress = make_report_progress ()
7080 urllib .request .urlretrieve (qairt_url , archive_path , report_progress )
71- print ("\n Download completed!" )
81+ print ("Download completed!" )
7282
7383 # Check if file was downloaded successfully
7484 if archive_path .exists ():
You can’t perform that action at this time.
0 commit comments