Spaces:
Paused
Paused
Update dl.py
Browse files
dl.py
CHANGED
|
@@ -272,14 +272,17 @@ def get_space_runtime(author,checklist,token):
|
|
| 272 |
return space_info
|
| 273 |
def delete_checked(confirm_val,author,checklist,token):
|
| 274 |
if confirm_val=="CONFIRM":
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
| 283 |
else:
|
| 284 |
yield "Not Deleting", gr.update(visible=False)
|
| 285 |
|
|
@@ -346,8 +349,10 @@ with gr.Blocks(css=css) as build:
|
|
| 346 |
dl_checked_btn=gr.Button("Download Checked")
|
| 347 |
delete_checked_btn=gr.Button("Delete Checked")
|
| 348 |
with gr.Row(visible=False) as sure_row:
|
| 349 |
-
|
| 350 |
-
|
|
|
|
|
|
|
| 351 |
gr.Column()
|
| 352 |
sure_check=gr.Textbox(visible=False,value="")
|
| 353 |
|
|
@@ -361,7 +366,7 @@ with gr.Blocks(css=css) as build:
|
|
| 361 |
return html
|
| 362 |
dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
|
| 363 |
delete_checked_btn.click(ru_sure_fn,None,sure_row)
|
| 364 |
-
ru_sure_btn.click(delete_checked,[ru_sure_box,r_name,space_check,token],[
|
| 365 |
|
| 366 |
space_check.change(update_checked_message,space_check,message_box)
|
| 367 |
|
|
|
|
| 272 |
return space_info
|
| 273 |
def delete_checked(confirm_val,author,checklist,token):
|
| 274 |
if confirm_val=="CONFIRM":
|
| 275 |
+
try:
|
| 276 |
+
api = HfApi(token=token)
|
| 277 |
+
s_ist = checklist
|
| 278 |
+
delete_list = []
|
| 279 |
+
for i,space_ea in enumerate(s_ist):
|
| 280 |
+
|
| 281 |
+
api.delete_repo(f'{author}/{space_ea}')
|
| 282 |
+
delete_list.append(f'Deleted:: {space_ea}\n')
|
| 283 |
+
yield delete_list,gr.update(visible=False)
|
| 284 |
+
except Exception as e:
|
| 285 |
+
yield e
|
| 286 |
else:
|
| 287 |
yield "Not Deleting", gr.update(visible=False)
|
| 288 |
|
|
|
|
| 349 |
dl_checked_btn=gr.Button("Download Checked")
|
| 350 |
delete_checked_btn=gr.Button("Delete Checked")
|
| 351 |
with gr.Row(visible=False) as sure_row:
|
| 352 |
+
with gr.Column():
|
| 353 |
+
ru_sure_box=gr.Textbox(label="type: 'CONFIRM' to confirm", value="")
|
| 354 |
+
ru_sure_btn=gr.Button("Confirm Delete")
|
| 355 |
+
del_message_box=gr.HTML()
|
| 356 |
gr.Column()
|
| 357 |
sure_check=gr.Textbox(visible=False,value="")
|
| 358 |
|
|
|
|
| 366 |
return html
|
| 367 |
dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
|
| 368 |
delete_checked_btn.click(ru_sure_fn,None,sure_row)
|
| 369 |
+
ru_sure_btn.click(delete_checked,[ru_sure_box,r_name,space_check,token],[del_message_box,sure_row])
|
| 370 |
|
| 371 |
space_check.change(update_checked_message,space_check,message_box)
|
| 372 |
|