Spaces:
Sleeping
Sleeping
| from global_vars import t, translations | |
| from app import Plugin | |
| import streamlit as st | |
| import torch | |
| from plugins.scansite import ScansitePlugin | |
| # Ajout des traductions spécifiques à ce plugin | |
| translations["en"].update({ | |
| "work_directory": "Work Directory", | |
| "page_title": "News watcher", | |
| "reset_database": "Reset database", | |
| }) | |
| translations["fr"].update({ | |
| "work_directory": "Répertoire de travail", | |
| "page_title": "Outil de veille", | |
| "reset_database": "Réinitialiser la base de données", | |
| }) | |
| class CommonPlugin(Plugin): | |
| def __init__(self, name, plugin_manager): | |
| super().__init__(name, plugin_manager) | |
| self.scansite_plugin = ScansitePlugin('scansite', plugin_manager) | |
| def get_config_fields(self): | |
| return { | |
| "work_directory": { | |
| "type": "text", | |
| "label": t("work_directory"), | |
| "default": "/home/joriel/Vidéos" | |
| }, | |
| "language": { | |
| "type": "select", | |
| "label": t("preferred_language"), | |
| "options": [("fr", "Français"), ("en", "Anglais")], | |
| "default": "fr" | |
| }, | |
| } | |
| def get_tabs(self): | |
| return [{"name": "Commun", "plugin": "common"}] | |
| def run(self, config): | |
| st.header("Common Plugin") | |
| st.write(f"{t('work_directory')}: {config['common']['work_directory']}") | |
| torch.cuda.empty_cache() | |
| st.write("CUDA memory reset") | |
| if st.button(t("reset_database")): | |
| self.scansite_plugin.reset_database() | |
| st.success(t("database_reset_success")) | |
| def remove_quotes(s): | |
| if s.startswith('"') and s.endswith('"'): | |
| return s[1:-1] | |
| return s | |