Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -488,30 +488,29 @@ def create_gradio_interface():
|
|
488 |
downloader = PaperDownloader()
|
489 |
|
490 |
def update_progress(message, log_message=""):
|
491 |
-
|
492 |
|
493 |
async def download_papers(bib_file, doi_input, dois_input):
|
494 |
-
progress_field = gr.HTML()
|
495 |
|
496 |
def custom_progress_callback(message):
|
497 |
logger.info(f"Callback message: {message}")
|
498 |
-
return
|
499 |
|
500 |
if bib_file:
|
501 |
# Check file type
|
502 |
if not bib_file.name.lower().endswith('.bib'):
|
503 |
-
return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file",
|
504 |
|
505 |
zip_path, downloaded_dois, failed_dois, _ = await downloader.process_bibtex_async(bib_file, custom_progress_callback)
|
506 |
-
return zip_path, downloaded_dois, failed_dois,
|
507 |
elif doi_input:
|
508 |
filepath, message, failed_doi, _ = await downloader.download_single_doi_async(doi_input,custom_progress_callback)
|
509 |
return None, message, failed_doi, "", filepath
|
510 |
elif dois_input:
|
511 |
zip_path, downloaded_dois, failed_dois, _ = await downloader.download_multiple_dois_async(dois_input, custom_progress_callback)
|
512 |
-
return zip_path, downloaded_dois, failed_dois,
|
513 |
else:
|
514 |
-
return None, "Please provide a .bib file, a single DOI, or a list of DOIs", "Please provide a .bib file, a single DOI, or a list of DOIs",
|
515 |
|
516 |
|
517 |
|
|
|
488 |
downloader = PaperDownloader()
|
489 |
|
490 |
def update_progress(message, log_message=""):
|
491 |
+
return gr.HTML(value=f"{message}"), gr.HTML(value=f"<pre>{log_message}</pre>")
|
492 |
|
493 |
async def download_papers(bib_file, doi_input, dois_input):
|
|
|
494 |
|
495 |
def custom_progress_callback(message):
|
496 |
logger.info(f"Callback message: {message}")
|
497 |
+
return update_progress(message)
|
498 |
|
499 |
if bib_file:
|
500 |
# Check file type
|
501 |
if not bib_file.name.lower().endswith('.bib'):
|
502 |
+
return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file", "", None
|
503 |
|
504 |
zip_path, downloaded_dois, failed_dois, _ = await downloader.process_bibtex_async(bib_file, custom_progress_callback)
|
505 |
+
return zip_path, downloaded_dois, failed_dois, "", None
|
506 |
elif doi_input:
|
507 |
filepath, message, failed_doi, _ = await downloader.download_single_doi_async(doi_input,custom_progress_callback)
|
508 |
return None, message, failed_doi, "", filepath
|
509 |
elif dois_input:
|
510 |
zip_path, downloaded_dois, failed_dois, _ = await downloader.download_multiple_dois_async(dois_input, custom_progress_callback)
|
511 |
+
return zip_path, downloaded_dois, failed_dois, "", None
|
512 |
else:
|
513 |
+
return None, "Please provide a .bib file, a single DOI, or a list of DOIs", "Please provide a .bib file, a single DOI, or a list of DOIs", "", None
|
514 |
|
515 |
|
516 |
|