Spaces:
Sleeping
Sleeping
import os | |
import sys | |
import requests | |
import importlib.util | |
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-310-x86_64-linux-gnu.so") | |
if os.path.exists(output_path): | |
st.write("File downloaded successfully.") | |
else: | |
st.write("Failed to download the file.") | |
# Adicione o diret贸rio dos m贸dulos ao PYTHONPATH | |
sys.path.append(current_dir) | |
# 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.") | |
st.write(dir(SynapseControl)) # Listar os atributos e m茅todos do m贸dulo para verificar se tudo est谩 carregado corretamente | |
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") | |