sync_page.py 1.37 KB
import streamlit as st
import importlib.util
import os
import sys

def load_module(module_name, file_path):
    module_dir = os.path.dirname(file_path)
    if module_dir not in sys.path:
        sys.path.insert(0, module_dir)
        
    spec = importlib.util.spec_from_file_location(module_name, file_path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module

def show():
    st.header("同步数据到审计库")
    st.info("请从左侧选择业务类型以加载对应的同步逻辑。")

def show_with_category(category):
    st.header(f"同步数据到审计库 - {category}")
    
    base_dir = os.path.dirname(os.path.abspath(__file__))
    
    if category == "E盾-智慧车管":
        module_path = os.path.join(base_dir, "edun", "edun_sync.py")
        try:
            module = load_module("edun_sync", module_path)
            module.show()
        except Exception as e:
            st.error(f"加载 E盾 同步模块失败: {e}")
            
    elif category == "嘀加-旧版本":
        #
        module_path = os.path.join(base_dir, "dijia", "dijia_sync.py")
        try:
            module = load_module("dijia_sync", module_path)
            module.show()
        except Exception as e:
            st.error(f"加载 嘀加 同步模块失败: {e}")
    else:
        st.warning(f"未知的业务类型: {category}")