Skip to content

Commit 3a3e907

Browse files
Improve --update and --debug flags, fix file comparison and edge cases
- Fixed crash when Git is not installed by implementing a proper existence check - Resolved issue where --debug misidentified ignored files as extra - Unified file comparison logic in --debug with _dev.py logic to avoid mismatches - Enhanced debug logging for better clarity and traceability - Fixed dev mode bug where, after max attempts, input was ignored even if valid - Added support for Python 3.13 in debug, thus no error will be thrown in the menu Signed-off-by: Shahm Najeeb <[email protected]>
1 parent 4245589 commit 3a3e907

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

CODE/Logicytics.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,18 @@ def update() -> tuple[str, str]:
264264
str: The output from the git pull command.
265265
"""
266266
# Check if git command is available
267-
if subprocess.run(["git", "--version"], capture_output=True).returncode != 0:
267+
try:
268+
if subprocess.run(["git", "--version"], capture_output=True).returncode != 0:
269+
return "Git is not installed or not available in the PATH.", "error"
270+
except FileNotFoundError:
268271
return "Git is not installed or not available in the PATH.", "error"
269272

270273
# Check if the project is a git repository
271-
if not os.path.exists(os.path.join(os.getcwd(), "../.git")):
272-
return "This project is not a git repository. The update flag uses git.", "error"
274+
try:
275+
if not os.path.exists(os.path.join(os.getcwd(), "../.git")):
276+
return "This project is not a git repository. The update flag uses git.", "error"
277+
except Exception as e:
278+
return f"Error checking for git repository: {e}", "error"
273279

274280
current_dir = os.getcwd()
275281
parent_dir = os.path.dirname(current_dir)

CODE/_debug.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import psutil
1010
import requests
1111

12-
from logicytics import Log, DEBUG, VERSION, check, config
12+
from logicytics import Log, DEBUG, VERSION, check, config, get
1313

1414
log_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "ACCESS\\LOGS\\DEBUG\\DEBUG.log")
1515
log = Log({"log_level": DEBUG, "filename": log_path, "truncate_message": False, "delete_log": True})
@@ -47,14 +47,16 @@ def check_required_files(directory: str, required_files: list[str]):
4747
log.error(f"Directory {directory} does not exist.")
4848
return
4949

50-
actual_files = []
51-
for root, _, files in os.walk(directory):
52-
for file in files:
53-
relative_path = os.path.relpath(os.path.join(root, file), start=directory)
54-
actual_files.append(relative_path.replace("\\", "/").replace('"', '')) # Normalize paths
50+
# Use get.list_of_files to retrieve files, excluding specified files, dirs, and extensions
51+
actual_files = get.list_of_files(
52+
directory,
53+
exclude_files=["logicytics/User_History.json.gz", "logicytics/User_History.json"],
54+
exclude_dirs=["SysInternal_Suite"],
55+
exclude_extensions=[".pyc"]
56+
)
57+
actual_files = [f.replace("\\", "/").replace('"', '') for f in actual_files] # Normalize paths
5558

5659
log.debug(f"Actual files found: {actual_files}")
57-
5860
# Strip quotes and normalize paths for comparison
5961
normalized_required_files = [
6062
required_file.strip().replace("\\", "/").replace('"', '') # Remove quotes and normalize paths
@@ -130,19 +132,21 @@ def python_version():
130132
"""
131133
version = sys.version.split()[0]
132134
MIN_VERSION = (3, 11)
133-
MAX_VERSION = (3, 13)
135+
MAX_VERSION = (3, 14)
134136
try:
135137
major, minor = map(int, version.split(".")[:2])
136138
if MIN_VERSION <= (major, minor) < MAX_VERSION:
137-
log.info(f"Python Version: {version} - Perfect")
139+
if (major, minor) == MIN_VERSION:
140+
log.info(f"Python Version: {version} - Perfect (mainly tested on 3.11.x)")
141+
else:
142+
log.info(f"Python Version: {version} - Supported")
138143
elif (major, minor) < MIN_VERSION:
139144
log.warning(f"Python Version: {version} - Recommended: 3.11.x")
140145
else:
141146
log.error(f"Python Version: {version} - Incompatible")
142147
except Exception as e:
143148
log.error(f"Failed to parse Python Version: {e}")
144149

145-
146150
class ConfigManager:
147151
@staticmethod
148152
def get_online_config() -> dict | None:
@@ -206,8 +210,8 @@ def debug():
206210
SysInternalManager.check_binaries("SysInternal_Suite")
207211

208212
# System Checks
209-
log.info("Admin privileges found" if check.admin() else "Admin privileges not found")
210-
log.info("UAC enabled" if check.uac() else "UAC disabled")
213+
log.info("Admin privileges found") if check.admin() else log.warning("Admin privileges not found")
214+
log.info("UAC enabled") if check.uac() else log.warning("UAC disabled")
211215
log.info(f"Execution path: {psutil.__file__}")
212216
log.info(f"Global execution path: {sys.executable}")
213217
log.info(f"Local execution path: {sys.prefix}")

CODE/_dev.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ def _handle_file_operations() -> None:
150150
while True:
151151
version = color_print(f"[?] Enter the new version of the project (Old version is {VERSION}): ", "cyan",
152152
is_input=True)
153-
if attempts >= max_attempts:
154-
color_print("[x] Maximum attempts reached. Please run the script again.", "red")
155-
exit()
153+
156154
if re.match(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$", version):
157155
_update_ini_file("config.ini", version, "version")
158156
break
157+
elif attempts >= max_attempts:
158+
color_print("[x] Maximum attempts reached. Please run the script again.", "red")
159+
exit()
159160
else:
160161
color_print("[!] Please enter a valid version number (e.g., 1.2.3)", "yellow")
161162
attempts += 1

0 commit comments

Comments
 (0)