import time from datetime import datetime import streamlit as st from apps.dump_analysis import dump_analysis_space from queries.process_all_db import process_all_tech_db, process_all_tech_db_with_stats from queries.process_gsm import process_gsm_data_to_excel from queries.process_lte import process_lte_data_to_excel # from queries.process_mal import process_mal_data_to_excel from queries.process_mrbts import process_mrbts_data_to_excel from queries.process_neighbors import process_neighbors_data_to_excel # from queries.process_trx import process_trx_with_bts_name_data_to_excel from queries.process_wcdma import process_wcdma_data_to_excel from utils.check_sheet_exist import DumpType, Technology, execute_checks_sheets_exist from utils.utils_vars import GsmAnalysisData, UtilsVars, WcdmaAnalysisData 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_{datetime.now()}.xlsx" elif database_type == "3G": data = UtilsVars.final_wcdma_database file_name = f"3G database_{datetime.now()}.xlsx" elif database_type == "LTE": data = UtilsVars.final_lte_database file_name = f"LTE database_{datetime.now()}.xlsx" elif database_type == "All": data = UtilsVars.final_all_database file_name = f"All databases_{datetime.now()}.xlsx" elif database_type == "NEI": data = UtilsVars.neighbors_database file_name = f"Neighbors databases_{datetime.now()}.xlsx" # elif database_type == "TRX": # data = UtilsVars.final_trx_database # file_name = f"TRX database_{datetime.now()}.xlsx" elif database_type == "MRBTS": data = UtilsVars.final_mrbts_database file_name = f"MRBTS database_{datetime.now()}.xlsx" # elif database_type == "MAL": # data = UtilsVars.final_mal_database # file_name = f"MAL database_{datetime.now()}.xlsx" st.download_button( type="primary", label=f"Download {database_type} Database File", data=data, file_name=file_name, mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ) def execute_process_all_tech_db(uploaded_file): if uploaded_file is not None: start_time = time.time() process_all_tech_db(uploaded_file) execution_time = time.time() - start_time st.write( f"All databases are generated. Execution time: {execution_time:.2f} seconds" ) download_button("All") def execute_process_all_tech_db_with_stats(uploaded_file): if uploaded_file is not None: start_time = time.time() process_all_tech_db_with_stats(uploaded_file) execution_time = time.time() - start_time st.write( f"All databases are generated. Execution time: {execution_time:.2f} seconds" ) download_button("All") col1, col2, col3, col4 = st.columns(4) col5, col6, col7, col8 = st.columns(4) if uploaded_file is not None: # UtilsVars.file_path = uploaded_file try: execute_checks_sheets_exist(uploaded_file) if ( Technology.gsm == False and Technology.wcdma == False and Technology.lte == False and Technology.neighbors == False and Technology.trx == False and Technology.mrbts == False ): st.error( """ Uploaded file does not contain required sheets for any technology. "gsm": ["BTS", "BCF", "TRX","MAL"], "wcdma": ["WCEL", "WBTS", "WNCEL"], "lte": ["LNBTS", "LNCEL", "LNCEL_FDD", "LNCEL_TDD"], "neighbors": ["ADCE", "ADJS", "ADJI", "ADJG", "ADJW", "BTS", "WCEL"], "trx": ["TRX", "BTS"], "mrbts": ["MRBTS"], "mal": ["MAL"], """ ) if ( Technology.gsm == True and Technology.wcdma == True and Technology.lte == True and Technology.trx == True and Technology.mrbts == True and Technology.mal == True ): DumpType.full_dump = True with col1: st.button( "Generate All DBs", on_click=lambda: execute_process_all_tech_db(uploaded_file), ) if Technology.gsm == True: with col2: st.button( "Generate 2G DB", on_click=lambda: process_database(process_gsm_data_to_excel, "2G"), ) if Technology.wcdma == True: with col3: st.button( "Generate 3G DB", on_click=lambda: process_database( process_wcdma_data_to_excel, "3G" ), ) if Technology.lte == True: with col4: st.button( "Generate LTE DB", on_click=lambda: process_database(process_lte_data_to_excel, "LTE"), ) # if Technology.trx == True: # with col5: # st.button( # "Generate TRX DB", # on_click=lambda: process_database( # process_trx_with_bts_name_data_to_excel, "TRX" # ), # ) if Technology.mrbts == True: with col5: st.button( "Generate MRBTS", on_click=lambda: process_database( process_mrbts_data_to_excel, "MRBTS" ), ) # if Technology.mal == True: # with col7: # st.button( # "Generate MAL", # on_click=lambda: process_database(process_mal_data_to_excel, "MAL"), # ) if Technology.neighbors == True: with col6: st.button( "Generate NEI DB", on_click=lambda: process_database( process_neighbors_data_to_excel, "NEI" ), ) except Exception as e: st.error(f"Error: {e}") ######################## ANALYTICS AND STATS #################################### if uploaded_file is not None: if DumpType.full_dump == True: if st.button("Generate All DBs and Show Stats"): execute_process_all_tech_db_with_stats(uploaded_file) dump_analysis_space()