teste / app.py
AlineIoste's picture
Update app.py
225f963 verified
raw
history blame
2.31 kB
import requests
import os
import importlib.util
import sys
import streamlit as st
def download_so():
url = "https://github.com/AlineIoste/teste/raw/main/SynapseControl.cpython-310-x86_64-linux-gnu.so"
current_dir = os.path.dirname(os.path.abspath(__file__))
output_path = os.path.join(current_dir, "SynapseControl.cpython-310-x86_64-linux-gnu.so")
if not os.path.exists(output_path):
response = requests.get(url)
response.raise_for_status() # Para garantir que o download foi bem-sucedido
with open(output_path, 'wb') as f:
f.write(response.content)
st.write(f"Downloaded {url} to {output_path}")
else:
st.write(f"File already exists at {output_path}")
# Execute o download
download_so()
# Verifique se o arquivo foi baixado corretamente
current_dir = os.path.dirname(os.path.abspath(__file__))
output_path = os.path.join(current_dir, "SynapseControl.cpython-38-x86_64-linux-gnu.so")
if os.path.exists(output_path):
st.write("File downloaded successfully.")
else:
st.write("Failed to download the file.")
# Verificar se todos os m贸dulos Python necess谩rios est茫o dispon铆veis
try:
import LongTermMemory
import ShortTermMemory
import SynapseControl as SC_Py
import Criptografia
st.write("Todos os m贸dulos Python foram importados com sucesso.")
except ModuleNotFoundError as e:
st.write(f"Erro ao importar m贸dulo: {e}")
# Carregar o m贸dulo SynapseControl usando importlib.util
module_name = "SynapseControl"
spec = importlib.util.spec_from_file_location(module_name, output_path)
SynapseControl = importlib.util.module_from_spec(spec)
sys.modules[module_name] = SynapseControl
try:
spec.loader.exec_module(SynapseControl)
st.write("SynapseControl module loaded successfully.")
# Verificar a exist锚ncia das fun莽玫es
functions = ["Initial_Memory", "Synapses_Active", "ExecuteModel"]
for func in functions:
if hasattr(SynapseControl, func):
st.write(f"{func} function is available.")
else:
st.write(f"{func} function is not found in the module.")
except Exception as e:
st.write(f"Error loading SynapseControl module: {e}")
# Continue com o restante da l贸gica do seu aplicativo Streamlit
st.title("Neurocognitive Structures")