Skip to content

Commit 5f1a266

Browse files
📝 Add docstrings to bug-fixes-and-v3.3.0 (#178)
> [!WARNING] > The [docstrings feature](https://docs.coderabbit.ai/finishing-touches/docstrings) is in [beta](https://docs.coderabbit.ai/early-access/#beta). Docstrings generation was requested by @DefinetlyNotAI. * #176 (comment) The following files were modified: * `CODE/Logicytics.py` * `CODE/_debug.py` * `CODE/_dev.py` * `CODE/bluetooth_details.py` * `CODE/bluetooth_logger.py` * `CODE/dir_list.py` * `CODE/dump_memory.py` * `CODE/event_log.py` * `CODE/log_miner.py` * `CODE/logicytics/Execute.py` * `CODE/logicytics/FileManagement.py` * `CODE/logicytics/Flag.py` * `CODE/logicytics/Get.py` * `CODE/logicytics/Logger.py` * `CODE/logicytics/__init__.py` * `CODE/media_backup.py` * `CODE/packet_sniffer.py` * `CODE/sensitive_data_miner.py` * `CODE/vulnscan.py` * `CODE/wifi_stealer.py` <details> <summary>These files were kept as they were</summary> * `CODE/sys_internal.py` </details> <details> <summary>These file types are not supported</summary> * `.github/ISSUE_TEMPLATE/bug_report.yml` * `.gitignore` * `CODE/config.ini` * `CREDITS.md` * `PLANS.md` * `README.md` * `SECURITY.md` * `requirements.txt` </details> <details> <summary>ℹ️ Note</summary><blockquote> CodeRabbit cannot perform edits on its own pull requests yet. </blockquote></details>
2 parents 940c015 + ccb9668 commit 5f1a266

20 files changed

+1261
-404
lines changed

CODE/Logicytics.py

Lines changed: 86 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,16 @@ def update() -> tuple[str, str]:
7575

7676
def get_flags():
7777
"""
78-
Retrieves the action and sub-action flags_list from the Flag module and logs them.
79-
80-
This function sets the global variables ACTION and SUB_ACTION based on the data
81-
retrieved from the Flag module. It also logs the retrieved values for debugging purposes.
78+
Retrieves action and sub-action flags from the Flag module and sets global variables.
79+
80+
This function extracts the current action and sub-action from the Flag module, setting global
81+
ACTION and SUB_ACTION variables. It logs the retrieved values for debugging and tracing purposes.
82+
83+
No parameters.
84+
85+
Side effects:
86+
- Sets global variables ACTION and SUB_ACTION
87+
- Logs debug information about current action and sub-action
8288
"""
8389
global ACTION, SUB_ACTION
8490
# Get flags_list
@@ -89,10 +95,22 @@ def get_flags():
8995

9096
def special_execute(file_path: str):
9197
"""
92-
Executes a Python script in a new command prompt window.
93-
94-
Args:
95-
file_path (str): The relative path to the Python script to be executed.
98+
Execute a Python script in a new command prompt window.
99+
100+
This function launches the specified Python script in a separate command prompt window, waits for its completion, and then exits the current process.
101+
102+
Parameters:
103+
file_path (str): The relative path to the Python script to be executed,
104+
which will be resolved relative to the current script's directory.
105+
106+
Side Effects:
107+
- Opens a new command prompt window
108+
- Runs the specified Python script
109+
- Terminates the current process after script execution
110+
111+
Raises:
112+
FileNotFoundError: If the specified script path does not exist
113+
subprocess.SubprocessError: If there are issues launching the subprocess
96114
"""
97115
sr_current_dir = os.path.dirname(os.path.abspath(__file__))
98116
sr_script_path = os.path.join(sr_current_dir, file_path)
@@ -103,12 +121,23 @@ def special_execute(file_path: str):
103121

104122
def handle_special_actions():
105123
"""
106-
Handles special actions based on the provided action flag.
107-
108-
This function checks the value of the `action` variable and performs
109-
corresponding special actions such as opening debug, developer, or extra
110-
tools menus, updating the repository, restoring backups, creating backups,
111-
or unzipping extra files.
124+
Handles special actions based on the current action flag.
125+
126+
This function performs specific actions depending on the global `ACTION` variable:
127+
- For "debug": Opens the debug menu by executing '_debug.py'
128+
- For "dev": Opens the developer menu by executing '_dev.py'
129+
- For "update": Updates the repository using Health.update() method
130+
- For "restore": Displays a warning and opens the backup location
131+
- For "backup": Creates backups of the CODE and MODS directories
132+
133+
Side Effects:
134+
- Logs informational, debug, warning, or error messages
135+
- May execute external Python scripts
136+
- May open file locations
137+
- May terminate the program after completing special actions
138+
139+
Raises:
140+
SystemExit: Exits the program after completing certain special actions
112141
"""
113142
# Special actions -> Quit
114143
if ACTION == "debug":
@@ -158,10 +187,18 @@ def handle_special_actions():
158187
def check_privileges():
159188
"""
160189
Checks if the script is running with administrative privileges and handles UAC (User Account Control) settings.
161-
190+
162191
This function verifies if the script has admin privileges. If not, it either logs a warning (in debug mode) or
163192
prompts the user to run the script with admin privileges and exits. It also checks if UAC is enabled and logs
164193
warnings accordingly.
194+
195+
Raises:
196+
SystemExit: If the script is not running with admin privileges and not in debug mode.
197+
198+
Notes:
199+
- Requires the `Check` module with `admin()` and `uac()` methods
200+
- Depends on global `DEBUG` configuration variable
201+
- Logs warnings or critical messages based on privilege and UAC status
165202
"""
166203
if not Check.admin():
167204
if DEBUG == "DEBUG":
@@ -178,10 +215,29 @@ def check_privileges():
178215

179216
def generate_execution_list() -> list | list[str] | list[str | Any]:
180217
"""
181-
Creates an execution list based on the provided action.
182-
218+
Generate an execution list of scripts based on the specified action.
219+
220+
This function dynamically creates a list of scripts to be executed by filtering and selecting
221+
scripts based on the global ACTION variable. It supports different execution modes:
222+
- 'minimal': A predefined set of lightweight scripts
223+
- 'nopy': PowerShell and script-based scripts without Python
224+
- 'modded': Includes scripts from the MODS directory
225+
- 'depth': Comprehensive script execution with data mining and logging scripts
226+
- 'vulnscan_ai': Vulnerability scanning script only
227+
228+
Parameters:
229+
None
230+
183231
Returns:
184-
list: The execution list of scripts to be executed.
232+
list[str]: A list of script file paths to be executed, filtered and modified based on the current action.
233+
234+
Raises:
235+
ValueError: Implicitly if a script file cannot be removed from the initial list.
236+
237+
Notes:
238+
- Removes sensitive or unnecessary scripts from the initial file list
239+
- Logs the final execution list for debugging purposes
240+
- Warns users about potential long execution times for certain actions
185241
"""
186242
execution_list = Get.list_of_files(".", extensions=(".py", ".exe", ".ps1", ".bat"))
187243
execution_list.remove("sensitive_data_miner.py")
@@ -345,16 +401,18 @@ def handle_sub_action():
345401
@log.function
346402
def Logicytics():
347403
"""
348-
Main function to run the Logicytics process.
349-
350-
This function performs the following steps:
351-
1. Retrieves command-line flags_list and configurations.
352-
2. Handles any special actions based on the provided action flag.
353-
3. Checks for administrative privileges and potential errors.
354-
4. Executes the scripts based on the action flag.
355-
5. Zips the generated files.
356-
6. Handles any sub-actions based on the provided sub-action flag.
357-
7. Waits for user input to exit the program.
404+
Orchestrates the complete Logicytics workflow, managing script execution, system actions, and user interactions.
405+
406+
This function serves as the primary entry point for the Logicytics utility, coordinating a series of system-level operations:
407+
- Retrieves command-line configuration flags
408+
- Processes special actions
409+
- Verifies system privileges
410+
- Executes targeted scripts
411+
- Compresses generated output files
412+
- Handles final system sub-actions
413+
- Provides a graceful exit mechanism
414+
415+
Performs actions sequentially without returning a value, designed to be the main execution flow of the Logicytics utility.
358416
"""
359417
# Get flags_list and configs
360418
get_flags()

CODE/_debug.py

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,28 @@ def cpu_info() -> tuple[str, str, str]:
179179

180180
def python_version():
181181
"""
182-
Checks the current Python version and logs the result.
183-
182+
Checks the current Python version against recommended version ranges and logs the result.
183+
184+
This function determines the compatibility of the current Python runtime by comparing its version
185+
against predefined minimum and maximum version thresholds. It provides informative logging about
186+
the Python version status.
187+
188+
Parameters:
189+
None
190+
184191
Logs:
185-
- Info if the Python version is within the acceptable range.
186-
- Warning if the Python version is below the minimum recommended version.
187-
- Error if the Python version is above the maximum supported version or if there is a parsing error.
192+
- Info: When Python version is within the recommended range (3.11.x to 3.12.x)
193+
- Warning: When Python version is below the minimum recommended version (< 3.11)
194+
- Error: When Python version is above the maximum supported version (>= 3.13) or parsing fails
195+
196+
Raises:
197+
No explicit exceptions are raised; errors are logged internally
198+
199+
Example:
200+
Typical log outputs might include:
201+
- "Python Version: 3.11.5 - Perfect"
202+
- "Python Version: 3.10.2 - Recommended: 3.11.x"
203+
- "Python Version: 3.13.0 - Incompatible"
188204
"""
189205
version = sys.version.split()[0]
190206
MIN_VERSION = (3, 11)
@@ -222,7 +238,25 @@ def get_online_config() -> dict | None:
222238
@log_debug.function
223239
def debug():
224240
"""
225-
Executes system checks and logs results.
241+
Executes a comprehensive system debug routine, performing various checks and logging system information.
242+
243+
This function performs the following tasks:
244+
- Clears the existing debug log file
245+
- Retrieves and validates online configuration
246+
- Checks system version compatibility
247+
- Verifies required file integrity
248+
- Checks SysInternal binaries
249+
- Logs system privileges and environment details
250+
- Checks Python version compatibility
251+
- Retrieves and logs CPU information
252+
253+
Logs are written to the debug log file, capturing system state, configuration, and potential issues.
254+
255+
Notes:
256+
- Requires admin privileges for full system checks
257+
- Logs information about execution environment
258+
- Checks system and Python version compatibility
259+
- Provides insights into system configuration and potential security settings
226260
"""
227261
# Clear Debug Log
228262
log_path = "../ACCESS/LOGS/DEBUG/DEBUG.log"

CODE/_dev.py

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ def _update_ini_file(filename: str, new_data: list | str, key: str) -> None:
4040

4141
def _prompt_user(question: str, file_to_open: str = None, special: bool = False) -> bool:
4242
"""
43-
Prompts the user with a question and optionally opens a file if the answer is not 'yes'.
44-
Args:
45-
question (str): The question to ask the user.
46-
file_to_open (str, optional): The file to open if the user doesn't answer 'yes'.
47-
Returns:
48-
bool: True if the user's answer is 'yes', otherwise False.
49-
"""
43+
Prompts the user with a yes/no question and optionally opens a file.
44+
45+
Parameters:
46+
question (str): The question to be presented to the user.
47+
file_to_open (str, optional): Path to a file that will be opened if the user does not respond affirmatively.
48+
special (bool, optional): Flag to suppress the default reminder message when the user responds negatively.
49+
50+
Returns:
51+
bool: True if the user responds with 'yes' or 'Y', False otherwise.
52+
53+
Raises:
54+
Exception: Logs any unexpected errors during user interaction.
55+
56+
Notes:
57+
- Uses subprocess to open files on Windows systems
58+
- Case-insensitive input handling for 'yes' responses
59+
- Provides optional file opening and reminder messaging
60+
"""
5061
try:
5162
answer = input(question + " (Y)es or (N)o:- ")
5263
if not (answer.lower() == "yes" or answer.lower() == "y"):
@@ -65,9 +76,32 @@ def _prompt_user(question: str, file_to_open: str = None, special: bool = False)
6576
@log_dev.function
6677
def dev_checks() -> None:
6778
"""
68-
Performs a series of checks to ensure that the developer has followed the required guidelines and best practices.
69-
Returns:
70-
bool: True if all checks pass, otherwise False.
79+
Performs comprehensive developer checks to ensure code quality and project guidelines compliance.
80+
81+
This function guides developers through a series of predefined checks, validates file additions,
82+
and updates project configuration. It performs the following key steps:
83+
- Verify adherence to contributing guidelines
84+
- Check file naming conventions
85+
- Validate file placement
86+
- Confirm docstring and comment coverage
87+
- Assess feature modularity
88+
- Categorize and display file changes
89+
- Update project configuration file
90+
91+
Raises:
92+
None: Returns None if any check fails or an error occurs during the process.
93+
94+
Side Effects:
95+
- Creates necessary directories
96+
- Prompts user for multiple confirmations
97+
- Prints file change lists with color coding
98+
- Updates configuration file with current files and version
99+
- Logs warnings or errors during the process
100+
101+
Example:
102+
Typical usage is during project development to ensure consistent practices:
103+
>>> dev_checks()
104+
# Interactively guides developer through project checks
71105
"""
72106
# Create the necessary directories if they do not exist
73107
FileManagement.mkdir()

0 commit comments

Comments
 (0)