Skip to content

Commit 16d4bf7

Browse files
committed
- 下载功能修复与优化
1 parent 6b370d4 commit 16d4bf7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ISAT/widgets/model_manager_dialog.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ def run(self):
4444
os.mkdir(tmp_root)
4545

4646
# 寻找最佳下载链接
47+
print('Getting the best download url ...')
4748
best_time = 1e8
4849
best_url = self.urls[0]
4950
for url in self.urls:
5051
try:
5152
start_time = time.time()
5253
req = request.Request(url, headers={"Range": "bytes=0-10"})
53-
request.urlopen(req, timeout=5)
54+
request.urlopen(req, timeout=3)
5455
cost_time = time.time() - start_time
5556
except:
5657
cost_time = 1e8
@@ -72,6 +73,7 @@ def run(self):
7273
total_size = int(response.headers['Content-Length'])
7374
except Exception as e:
7475
print('When download {} from {}, {}'.format(self.name, best_url, e))
76+
self.tag.emit(-1, -1)
7577
return
7678
# 存在缓存
7779
if downloaded_size != 0:
@@ -300,7 +302,8 @@ def pause(self, model_name):
300302
def delete(self, model_name):
301303
button = self.sender()
302304
try:
303-
os.remove(os.path.join(CHECKPOINT_PATH, model_name))
305+
if os.path.exists(os.path.join(CHECKPOINT_PATH, model_name)):
306+
os.remove(os.path.join(CHECKPOINT_PATH, model_name))
304307
button.setText('download')
305308
button.setStyleSheet('QWidget {color: %s}' % 'green')
306309
button.setEnabled(False)

0 commit comments

Comments
 (0)