import time import streamlit as st from queries.process_gsm import process_gsm_data from queries.process_lte import process_lte_data from queries.process_wcdma import process_wcdma_data from utils.utils_vars import UtilsVars st.title("Database processing") uploaded_file = st.file_uploader("Upload updated dump file", type="xlsb") def process_database(process_func, database_type): if uploaded_file is not None: start_time = time.time() process_func(uploaded_file) execution_time = time.time() - start_time st.write( f"{database_type} database is generated. Execution time: {execution_time:.2f} seconds" ) download_button(database_type) def download_button(database_type): if database_type == "2G": data = UtilsVars.final_gsm_database file_name = f"2G database_{time.time()}.xlsx" elif database_type == "3G": data = UtilsVars.final_wcdma_database file_name = f"3G database_{time.time()}.xlsx" elif database_type == "LTE": data = UtilsVars.final_lte_database file_name = f"LTE database_{time.time()}.xlsx" st.download_button( label=f"Download {database_type} Database File", data=data, file_name=file_name, mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ) col1, col2, col3 = st.columns(3) if uploaded_file is not None: with col1: st.button( "Generate 2G Database", on_click=lambda: process_database(process_gsm_data, "2G"), ) with col2: st.button( "Generate 3G Database", on_click=lambda: process_database(process_wcdma_data, "3G"), ) with col3: st.button( "Generate LTE Database", on_click=lambda: process_database(process_lte_data, "LTE"), )