Skip to content

Commit ae9b2c6

Browse files
Refactor file management and flag handling; update requirements for sentence-transformers
Signed-off-by: Shahm Najeeb <[email protected]>
1 parent 6d1e0af commit ae9b2c6

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

CODE/logicytics/FileManagement.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def open_file(file: str, use_full_path: bool = False) -> str | None:
3030
subprocess.run(["start", file_path], shell=False)
3131
except Exception as e:
3232
return f"Error opening file: {e}"
33+
return None
3334

3435
@staticmethod
3536
def mkdir():
@@ -145,6 +146,7 @@ def __remove_files(path: str, files: list) -> str | None:
145146
os.remove(os.path.join(path, file))
146147
except Exception as e:
147148
return f"Error: {e}"
149+
return None
148150

149151
@staticmethod
150152
def __generate_sha256_hash(filename: str) -> str:

CODE/logicytics/Flag.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __get_sim(user_input: str, all_descriptions: list[str]) -> list[float]:
5353
"""
5454
# Encode the current user input and historical inputs
5555
from sentence_transformers import SentenceTransformer, util
56-
5756
import logging # Suppress logging messages from Sentence Transformer due to verbosity
5857
# Set the logging level based on the debug mode, either DEBUG or ERROR (aka only important messages)
5958
if DEBUG_MODE:
@@ -211,14 +210,14 @@ def _generate_summary_and_graph(cls):
211210
log.info("\nFlag Usage Summary Graph saved in current working directory as 'Flag_usage_summary.png'")
212211

213212
@staticmethod
214-
def load_history() -> dict[str, any]:
213+
def load_history() -> dict:
215214
"""
216215
Load user interaction history from a gzipped JSON file.
217216
218217
This method attempts to read and parse historical interaction data from a compressed JSON file. If the file is not found, it returns an empty history structure with an empty interactions dictionary and a zero-initialized flags usage counter.
219218
220219
Returns:
221-
dict[str, any]: A dictionary containing:
220+
dict: A dictionary containing:
222221
- 'interactions': A dictionary of past user interactions
223222
- 'flags_usage': A Counter object tracking flag usage frequencies
224223
@@ -233,7 +232,7 @@ def load_history() -> dict[str, any]:
233232
return {'interactions': {}, 'flags_usage': Counter()}
234233

235234
@staticmethod
236-
def save_history(history_data: dict[str, any]):
235+
def save_history(history_data: dict):
237236
"""
238237
Save user interaction history to a gzipped JSON file.
239238

CODE/packet_sniffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def sniff_packets(self, iface: str, count: int, timeout: int, retry_max: int):
112112
)
113113
log.info("Sniff complete.")
114114
break
115-
except Exception as e:
116-
log.warning(f"Sniff failed on {iface}: {e}")
115+
except Exception as err:
116+
log.warning(f"Sniff failed on {iface}: {err}")
117117
iface = self._correct_interface(iface)
118118
else:
119119
log.error("Max retry time exceeded.")

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ matplotlib~=3.10.1
1616
networkx~=3.2.1
1717
pandas~=2.2.3
1818
cryptography~=44.0.2
19-
scapy~=2.5.0
19+
scapy~=2.5.0
20+
sentence-transformers~=5.0.0

0 commit comments

Comments
 (0)