generic_error_tab_advanced.py 998 B

1234567891011121314151617181920212223242526
  1. import traceback
  2. import gradio as gr
  3. from tts_webui.utils.pip_install import pip_install_wrapper
  4. def generic_error_tab_advanced(e: Exception, name="", requirements=None):
  5. with gr.Tab(name + " (!)"):
  6. gr.Markdown(f"Failed to load {name} tab. Please check your configuration.")
  7. gr.Markdown(f"Error: {e}")
  8. gr.Markdown(f"Stacktrace: {traceback.format_exc()}")
  9. print(f"Failed to load {name} tab. Please check your configuration.")
  10. print(f"Error: {e}")
  11. print(f"Stacktrace: {traceback.format_exc()}")
  12. if requirements:
  13. gr.Markdown(f"Please install the {requirements} file")
  14. gr.Markdown("Please check the console for more information")
  15. install_btn = gr.Button(f"Install {name}")
  16. gr.Markdown("Installation console:")
  17. console_text = gr.HTML()
  18. install_btn.click(
  19. pip_install_wrapper(requirements, name),
  20. outputs=[console_text],
  21. )