DavMelchi commited on
Commit
123d5ff
·
1 Parent(s): 263b2ce

adding documentation and core creation checking

Browse files
app.py CHANGED
@@ -1,127 +1,15 @@
1
- import time
2
-
3
  import streamlit as st
4
 
5
- from queries.process_all_db import process_all_tech_db
6
- from queries.process_gsm import process_gsm_data_to_excel
7
- from queries.process_lte import process_lte_data_to_excel
8
- from queries.process_neighbors import (
9
- process_neighbors_data,
10
- process_neighbors_data_to_excel,
11
- )
12
- from queries.process_wcdma import process_wcdma_data_to_excel
13
- from utils.check_sheet_exist import Technology, execute_checks_sheets_exist
14
- from utils.utils_vars import UtilsVars
15
-
16
- st.title("Database processing")
17
-
18
- uploaded_file = st.file_uploader("Upload updated dump file", type="xlsb")
19
-
20
-
21
- def process_database(process_func, database_type):
22
- if uploaded_file is not None:
23
- start_time = time.time()
24
- process_func(uploaded_file)
25
- execution_time = time.time() - start_time
26
- st.write(
27
- f"{database_type} database is generated. Execution time: {execution_time:.2f} seconds"
28
- )
29
- download_button(database_type)
30
-
31
-
32
- def download_button(database_type):
33
- if database_type == "2G":
34
- data = UtilsVars.final_gsm_database
35
- file_name = f"2G database_{time.time()}.xlsx"
36
- elif database_type == "3G":
37
- data = UtilsVars.final_wcdma_database
38
- file_name = f"3G database_{time.time()}.xlsx"
39
- elif database_type == "LTE":
40
- # data = UtilsVars.final_lte_database
41
- data = UtilsVars.final_lte_database
42
- file_name = f"LTE database_{time.time()}.xlsx"
43
- elif database_type == "All":
44
- data = UtilsVars.final_all_database
45
- file_name = f"All database_{time.time()}.xlsx"
46
- elif database_type == "NEI":
47
- data = UtilsVars.neighbors_database
48
- file_name = f"Neighbors database_{time.time()}.xlsx"
49
- st.download_button(
50
- type="primary",
51
- label=f"Download {database_type} Database File",
52
- data=data,
53
- file_name=file_name,
54
- mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
55
- )
56
-
57
-
58
- def execute_process_all_tech_db(uploaded_file):
59
- if uploaded_file is not None:
60
- start_time = time.time()
61
- process_all_tech_db(uploaded_file)
62
- execution_time = time.time() - start_time
63
- st.write(
64
- f"All databases are generated. Execution time: {execution_time:.2f} seconds"
65
- )
66
- download_button("All")
67
-
68
-
69
- col1, col2, col3, col4 = st.columns(4)
70
- col5, col6, col7, col8 = st.columns(4)
71
- if uploaded_file is not None:
72
- # UtilsVars.file_path = uploaded_file
73
- try:
74
- execute_checks_sheets_exist(uploaded_file)
75
- if (
76
- Technology.gsm == False
77
- and Technology.wcdma == False
78
- and Technology.lte == False
79
- ):
80
- st.error(
81
- """
82
- Uploaded file does not contain required sheets for any technology.
83
- "gsm": ["BTS", "BCF", "TRX"],
84
- "wcdma": ["WCEL", "WBTS", "WNCEL"],
85
- "lte": ["LNBTS", "LNCEL", "LNCEL_FDD", "LNCEL_TDD"],
86
- "neighbors": ["ADCE", "ADJS", "ADJI", "ADJG", "ADJW", "BTS", "WCEL"],
87
- """
88
- )
89
-
90
- if Technology.gsm == True:
91
- with col1:
92
- st.button(
93
- "Generate 2G DB",
94
- on_click=lambda: process_database(process_gsm_data_to_excel, "2G"),
95
- )
96
- if Technology.wcdma == True:
97
- with col2:
98
- st.button(
99
- "Generate 3G DB",
100
- on_click=lambda: process_database(
101
- process_wcdma_data_to_excel, "3G"
102
- ),
103
- )
104
- if Technology.lte == True:
105
- with col3:
106
- st.button(
107
- "Generate LTE DB",
108
- on_click=lambda: process_database(process_lte_data_to_excel, "LTE"),
109
- )
110
- if Technology.gsm == True or Technology.wcdma == True or Technology.lte == True:
111
- with col4:
112
- st.button(
113
- "Generate All DBs",
114
- on_click=lambda: execute_process_all_tech_db(uploaded_file),
115
- )
116
- if Technology.neighbors == True:
117
- with col5:
118
- st.button(
119
- "Generate NEI DB",
120
- on_click=lambda: process_database(
121
- process_neighbors_data_to_excel, "NEI"
122
- ),
123
- # on_click=lambda: process_neighbors_data(uploaded_file),
124
- )
125
-
126
- except Exception as e:
127
- st.error(f"Error: {e}")
 
 
 
1
  import streamlit as st
2
 
3
+ pages = {
4
+ "Apps": [
5
+ st.Page("apps/database_page.py", title="Generate Databases"),
6
+ st.Page("apps/core_dump_page.py", title="Check dump core"),
7
+ ],
8
+ "Documentations": [
9
+ st.Page("documentations/database_doc.py", title="Databases Documentation"),
10
+ st.Page("documentations/core_dump_doc.py", title="Dump core Documentation"),
11
+ ],
12
+ }
13
+
14
+ pg = st.navigation(pages)
15
+ pg.run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
apps/core_dump_page.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+ st.title("Core Creation Dump")
5
+
6
+ # Initialize a list to hold the extracted data
7
+ data_global_cell_id = []
8
+ data_la_cell_name = []
9
+ data_wcdma_service_area_number = []
10
+ data_wcdma_service_area_name = []
11
+
12
+
13
+ # Create a Streamlit file uploader
14
+ uploaded_files = st.file_uploader(
15
+ "Upload Core Creation dump files", type=["txt"], accept_multiple_files=True
16
+ )
17
+
18
+
19
+ # Process each uploaded file
20
+ if uploaded_files:
21
+
22
+ all_data_global_cell_id = []
23
+ all_data_la_cell_name = []
24
+ all_data_wcdma_service_area_number = []
25
+ all_data_wcdma_service_area_name = []
26
+
27
+ for file in uploaded_files:
28
+ # Read the content of the file
29
+
30
+ content = file.read().decode("utf-8").splitlines()
31
+ data_global_cell_id = []
32
+ data_la_cell_name = []
33
+ data_wcdma_service_area_number = []
34
+ data_wcdma_service_area_name = []
35
+
36
+ # Loop through each line in the file
37
+ for line in content:
38
+ if "Global cell ID" in line:
39
+ data_global_cell_id.append([line.split("=")[1].strip()])
40
+ elif "LA cell name" in line:
41
+ data_la_cell_name.append([line.split("=")[1].strip()])
42
+ elif "3G service area number" in line:
43
+ data_wcdma_service_area_number.append([line.split("=")[1].strip()])
44
+ elif "3G service area name" in line:
45
+ data_wcdma_service_area_name.append([line.split("=")[1].strip()])
46
+
47
+ # Append the extracted data for the current file to the overall lists
48
+ all_data_global_cell_id.extend(data_global_cell_id)
49
+ all_data_la_cell_name.extend(data_la_cell_name)
50
+ all_data_wcdma_service_area_number.extend(data_wcdma_service_area_number)
51
+ all_data_wcdma_service_area_name.extend(data_wcdma_service_area_name)
52
+
53
+ # Create a DataFrame from the extracted data
54
+ df_global_cell_id = pd.DataFrame(
55
+ all_data_global_cell_id, columns=["Global cell ID"]
56
+ )
57
+ df_la_cell_name = pd.DataFrame(all_data_la_cell_name, columns=["LA cell name"])
58
+ df_wcdma_service_area_number = pd.DataFrame(
59
+ all_data_wcdma_service_area_number, columns=["3G service area number"]
60
+ )
61
+ df_wcdma_service_area_name = pd.DataFrame(
62
+ all_data_wcdma_service_area_name, columns=["3G service area name"]
63
+ )
64
+
65
+ # add index column df_global_cell_id and df_la_cell_name and dfa_wcdma_service_area_numbera and df_wcdma_service_area_name
66
+ df_global_cell_id.insert(0, "index", range(0, len(df_global_cell_id)))
67
+ df_la_cell_name.insert(0, "index", range(0, len(df_la_cell_name)))
68
+ df_wcdma_service_area_number.insert(
69
+ 0, "index", range(0, len(df_wcdma_service_area_number))
70
+ )
71
+ df_wcdma_service_area_name.insert(
72
+ 0, "index", range(0, len(df_wcdma_service_area_name))
73
+ )
74
+
75
+ # Merge global_cell_id and la_cell_name on index
76
+ df_la_cell_name = df_la_cell_name.merge(df_global_cell_id, on="index")
77
+
78
+ # merge wcdma_service_area_number and wcdma_service_area_name on index
79
+ df_wcdma_service_area_name = df_wcdma_service_area_name.merge(
80
+ df_wcdma_service_area_number, on="index"
81
+ )
82
+
83
+ df_la_cell_name["LAC_ID"] = df_la_cell_name["Global cell ID"].str[5:]
84
+ df_wcdma_service_area_name["LAC_ID"] = df_wcdma_service_area_name[
85
+ "3G service area number"
86
+ ].str[5:]
87
+ df_la_cell_name["LAC"] = df_la_cell_name["LAC_ID"].str[:4]
88
+ df_la_cell_name["Cell ID"] = df_la_cell_name["LAC_ID"].str[4:]
89
+ df_wcdma_service_area_name["LAC"] = df_wcdma_service_area_name["LAC_ID"].str[:4]
90
+ df_wcdma_service_area_name["Cell ID"] = df_wcdma_service_area_name["LAC_ID"].str[4:]
91
+
92
+ # convert LAC to from HEXadecimal to DECimal
93
+ df_la_cell_name["LAC_DECIMAL"] = df_la_cell_name["LAC"].apply(lambda x: int(x, 16))
94
+ df_la_cell_name["Cell_ID_DECIMAL"] = df_la_cell_name["Cell ID"].apply(
95
+ lambda x: int(x, 16)
96
+ )
97
+ df_wcdma_service_area_name["LAC_DECIMAL"] = df_wcdma_service_area_name["LAC"].apply(
98
+ lambda x: int(x, 16)
99
+ )
100
+ df_wcdma_service_area_name["Cell_ID_DECIMAL"] = df_wcdma_service_area_name[
101
+ "Cell ID"
102
+ ].apply(lambda x: int(x, 16))
103
+
104
+ df_la_cell_name = df_la_cell_name.reset_index(drop=True)
105
+
106
+ # Display the DataFrame
107
+ st.subheader("2G CORE DUMP DATA")
108
+ st.write(df_la_cell_name)
109
+ st.subheader("3G CORE DUMP DATA")
110
+ st.write(df_wcdma_service_area_name)
apps/database_page.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+
3
+ import streamlit as st
4
+
5
+ from queries.process_all_db import process_all_tech_db
6
+ from queries.process_gsm import process_gsm_data_to_excel
7
+ from queries.process_lte import process_lte_data_to_excel
8
+ from queries.process_neighbors import (
9
+ process_neighbors_data,
10
+ process_neighbors_data_to_excel,
11
+ )
12
+ from queries.process_wcdma import process_wcdma_data_to_excel
13
+ from utils.check_sheet_exist import Technology, execute_checks_sheets_exist
14
+ from utils.utils_vars import UtilsVars
15
+
16
+ st.title("Database processing")
17
+
18
+ uploaded_file = st.file_uploader("Upload updated dump file", type="xlsb")
19
+
20
+
21
+ def process_database(process_func, database_type):
22
+ if uploaded_file is not None:
23
+ start_time = time.time()
24
+ process_func(uploaded_file)
25
+ execution_time = time.time() - start_time
26
+ st.write(
27
+ f"{database_type} database is generated. Execution time: {execution_time:.2f} seconds"
28
+ )
29
+ download_button(database_type)
30
+
31
+
32
+ def download_button(database_type):
33
+ if database_type == "2G":
34
+ data = UtilsVars.final_gsm_database
35
+ file_name = f"2G database_{time.time()}.xlsx"
36
+ elif database_type == "3G":
37
+ data = UtilsVars.final_wcdma_database
38
+ file_name = f"3G database_{time.time()}.xlsx"
39
+ elif database_type == "LTE":
40
+ # data = UtilsVars.final_lte_database
41
+ data = UtilsVars.final_lte_database
42
+ file_name = f"LTE database_{time.time()}.xlsx"
43
+ elif database_type == "All":
44
+ data = UtilsVars.final_all_database
45
+ file_name = f"All database_{time.time()}.xlsx"
46
+ elif database_type == "NEI":
47
+ data = UtilsVars.neighbors_database
48
+ file_name = f"Neighbors database_{time.time()}.xlsx"
49
+ st.download_button(
50
+ type="primary",
51
+ label=f"Download {database_type} Database File",
52
+ data=data,
53
+ file_name=file_name,
54
+ mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
55
+ )
56
+
57
+
58
+ def execute_process_all_tech_db(uploaded_file):
59
+ if uploaded_file is not None:
60
+ start_time = time.time()
61
+ process_all_tech_db(uploaded_file)
62
+ execution_time = time.time() - start_time
63
+ st.write(
64
+ f"All databases are generated. Execution time: {execution_time:.2f} seconds"
65
+ )
66
+ download_button("All")
67
+
68
+
69
+ col1, col2, col3, col4 = st.columns(4)
70
+ col5, col6, col7, col8 = st.columns(4)
71
+ if uploaded_file is not None:
72
+ # UtilsVars.file_path = uploaded_file
73
+ try:
74
+ execute_checks_sheets_exist(uploaded_file)
75
+ if (
76
+ Technology.gsm == False
77
+ and Technology.wcdma == False
78
+ and Technology.lte == False
79
+ ):
80
+ st.error(
81
+ """
82
+ Uploaded file does not contain required sheets for any technology.
83
+ "gsm": ["BTS", "BCF", "TRX"],
84
+ "wcdma": ["WCEL", "WBTS", "WNCEL"],
85
+ "lte": ["LNBTS", "LNCEL", "LNCEL_FDD", "LNCEL_TDD"],
86
+ "neighbors": ["ADCE", "ADJS", "ADJI", "ADJG", "ADJW", "BTS", "WCEL"],
87
+ """
88
+ )
89
+
90
+ if Technology.gsm == True:
91
+ with col1:
92
+ st.button(
93
+ "Generate 2G DB",
94
+ on_click=lambda: process_database(process_gsm_data_to_excel, "2G"),
95
+ )
96
+ if Technology.wcdma == True:
97
+ with col2:
98
+ st.button(
99
+ "Generate 3G DB",
100
+ on_click=lambda: process_database(
101
+ process_wcdma_data_to_excel, "3G"
102
+ ),
103
+ )
104
+ if Technology.lte == True:
105
+ with col3:
106
+ st.button(
107
+ "Generate LTE DB",
108
+ on_click=lambda: process_database(process_lte_data_to_excel, "LTE"),
109
+ )
110
+ if Technology.gsm == True or Technology.wcdma == True or Technology.lte == True:
111
+ with col4:
112
+ st.button(
113
+ "Generate All DBs",
114
+ on_click=lambda: execute_process_all_tech_db(uploaded_file),
115
+ )
116
+ if Technology.neighbors == True:
117
+ with col5:
118
+ st.button(
119
+ "Generate NEI DB",
120
+ on_click=lambda: process_database(
121
+ process_neighbors_data_to_excel, "NEI"
122
+ ),
123
+ # on_click=lambda: process_neighbors_data(uploaded_file),
124
+ )
125
+
126
+ except Exception as e:
127
+ st.error(f"Error: {e}")
documentations/core_dump_doc.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.markdown(
4
+ """
5
+ ## Core Dump Page Documentation
6
+
7
+ ### Overview
8
+ This script is designed to process and display core dump files. It provides a user-friendly interface for uploading files, processing data, and displaying the results.
9
+
10
+ ### Getting Started
11
+ Upload a core dump file: Use the file uploader to select a core dump file in .txt format.
12
+ Process the data: Once the file is uploaded, the app will process the data and display the results.
13
+ Use the "Download icon" in the table to download the processed data.
14
+
15
+
16
+ ### Data Processed and Display
17
+ The processed data is displayed in the following format:
18
+
19
+ - Global Cell ID: The global cell ID is displayed in a table format.
20
+ - LA Cell Name: The LA cell name is displayed in a table format.
21
+ - WCDMA Service Area Number: The WCDMA service area number is displayed in a table format.
22
+ - WCDMA Service Area Name: The WCDMA service area name is displayed in a table format.
23
+
24
+
25
+ ### Troubleshooting
26
+ 1. Error messages: If an error occurs during processing, an error message will be displayed. Please check the file format and contents before trying again.
27
+ 2. File format: Only .txt files are supported. Please convert your file to the correct format before uploading.
28
+
29
+
30
+ ### Contact
31
+ If you have any questions or issues with the app, please contact [Dav Melchi] at [[email protected]].
32
+
33
+ """
34
+ )
documentations/database_doc.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.markdown(
4
+ """
5
+ ## Database Processing App Documentation
6
+ ### Overview
7
+ This app is designed to process and generate databases from uploaded dump files. It provides a user-friendly interface for uploading files, selecting database types, and downloading processed databases.
8
+
9
+ ### Getting Started
10
+ 1. Upload a dump file: Click on the "Upload updated dump file" button to select a file in .xlsb format.
11
+ 2. Select a database type: Choose a database type from the available options (2G, 3G, LTE, All, or NEI).
12
+ 3. Download the processed database: Once the processing is complete, click on the "Download" button to save the processed database in .xlsx format.
13
+
14
+ ### Required Sheets
15
+ The app requires the following sheets to be present in the uploaded file:
16
+
17
+ 1. **2G :**
18
+ - BTS
19
+ - BCF
20
+ - TRX
21
+ 2. **3G :**
22
+ - WCEL
23
+ - WBTS
24
+ - WNCEL
25
+ 3. **LTE :**
26
+ - LNBTS
27
+ - LNCEL
28
+ - LNCEL_FDD
29
+ - LNCEL_TDD
30
+ 4. **NEI :**
31
+ - ADCE
32
+ - ADJS
33
+ - ADJI
34
+ - ADJG
35
+ - ADJW
36
+ - BTS
37
+ - WCEL
38
+
39
+ Please ensure that these sheets are present in the uploaded file to avoid any errors.
40
+
41
+ ### Database Types
42
+ The app supports the following database types:
43
+
44
+ - 2G: Process 2G database
45
+ - 3G: Process 3G database
46
+ - LTE: Process LTE database
47
+ - All: Process all databases (2G, 3G, and LTE)
48
+ - NEI: Process neighbors database
49
+
50
+ ### Troubleshooting
51
+
52
+ - Error messages: If an error occurs during processing, an error message will be displayed. Please check the file format and required sheets before trying again.
53
+ - File format: Only .xlsb files are supported. Please convert your file to the correct format before uploading.
54
+
55
+
56
+
57
+ ### FAQ
58
+ - What is the maximum file size allowed?: The maximum file size allowed is 200MB.
59
+ - How long does the processing take?: The processing time depends on the file size and complexity. Please wait for the processing to complete.
60
+
61
+
62
+ ### Contact
63
+ If you have any questions or issues with the app, please contact [Dav Melchi] at [[email protected]].
64
+
65
+ """
66
+ )