Spaces:
Running
Running
File size: 1,720 Bytes
f34a6fd a497607 f34a6fd a497607 f34a6fd a497607 f34a6fd a497607 f34a6fd a497607 f34a6fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
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
|