Skip to content

Commit

Permalink
Formatted code black . and fixed bug where dev.py was called instea…
Browse files Browse the repository at this point in the history
…d of _dev.py
  • Loading branch information
DefinetlyNotAI committed Sep 20, 2024
1 parent a7e5655 commit 51336d3
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 47 deletions.
3 changes: 2 additions & 1 deletion CODE/Logicytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from _hide_my_tracks import attempt_hide
from _zipper import Zip
from __lib_class import *

log = Log(debug=DEBUG)
log_funcs = {
"INFO": log.info,
Expand Down Expand Up @@ -60,7 +61,7 @@
check_status.sys_internal_zip()

if action == "dev":
Execute().execute_script("dev.py")
Execute().execute_script("_dev.py")
input("Press Enter to exit...")
exit(0)

Expand Down
28 changes: 15 additions & 13 deletions CODE/__lib_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def __parse_arguments() -> tuple[argparse.Namespace, argparse.ArgumentParser]:
"--dev",
action="store_true",
help="Run Logicytics developer mod, this is only for people who want to register their contributions "
"properly. - Use on your own device only -.",
"properly. - Use on your own device only -.",
)
parser.add_argument(
"--exe",
action="store_true",
help="Run Logicytics using its precompiled exe's, These may be outdated and not the best, use only if the "
"device doesnt have python installed.",
"device doesnt have python installed.",
)
parser.add_argument(
"--debug",
Expand Down Expand Up @@ -152,7 +152,7 @@ def __exclusivity(args: argparse.Namespace) -> bool:
special_flag_used = False
if args.reboot or args.shutdown or args.webhook:
if not (
args.default or args.threaded or args.modded or args.minimal or args.exe
args.default or args.threaded or args.modded or args.minimal or args.exe
):
print("Invalid combination of flags.")
exit(1)
Expand Down Expand Up @@ -236,11 +236,11 @@ def read_config() -> tuple[str, bool, str, str, list[str]]:
files = data.get("CURRENT_FILES", [])

if not (
isinstance(webhook_url, str)
and isinstance(debug, bool)
and isinstance(version, str)
and isinstance(api_key, str)
and isinstance(files, list)
isinstance(webhook_url, str)
and isinstance(debug, bool)
and isinstance(version, str)
and isinstance(api_key, str)
and isinstance(files, list)
):
print("Invalid config.json format.")
input("Press Enter to exit...")
Expand Down Expand Up @@ -343,12 +343,14 @@ def sys_internal_zip():
if zip_file and not ignore_file:
print("Extracting SysInternal_Suite zip")
with zipfile.ZipFile(
"SysInternal_Suite/SysInternal_Suite.zip"
"SysInternal_Suite/SysInternal_Suite.zip"
) as zip_ref:
zip_ref.extractall("SysInternal_Suite")

elif ignore_file:
print("Found .sys.ignore file, skipping SysInternal_Suite zip extraction")
print(
"Found .sys.ignore file, skipping SysInternal_Suite zip extraction"
)

except Exception as err:
print(f"Failed to unzip SysInternal_Suite: {err}", "_L", "G", "CS")
Expand All @@ -368,9 +370,9 @@ def get_files(directory: str, file_list: list) -> list:
"""
for filename in os.listdir(directory):
if (
filename.endswith((".py", ".exe", ".ps1", ".bat"))
and not filename.startswith("_")
and filename != "Logicytics.py"
filename.endswith((".py", ".exe", ".ps1", ".bat"))
and not filename.startswith("_")
and filename != "Logicytics.py"
):
file_list.append(filename)
return file_list
Expand Down
85 changes: 65 additions & 20 deletions CODE/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import psutil
import sys
from __lib_class import *

if __name__ == "__main__":
log_debug = Log(debug=DEBUG, filename="../ACCESS/LOGS/DEBUG/DEBUG.LOG")
log_debug_funcs = {
Expand All @@ -17,7 +18,9 @@


class HealthCheck:
def get_online_config(self) -> bool | tuple[tuple[str, str, str], tuple[str, str, str]]:
def get_online_config(
self,
) -> bool | tuple[tuple[str, str, str], tuple[str, str, str]]:
"""
Retrieves configuration data from a remote repository and compares it with the local configuration.
Expand All @@ -31,13 +34,15 @@ def get_online_config(self) -> bool | tuple[tuple[str, str, str], tuple[str, str
except requests.exceptions.ConnectionError:
log_debug.warning("No connection found")
return False
version_check = self.__compare_versions(VERSION, config['VERSION'])
file_check = self.__check_files(CURRENT_FILES, config['CURRENT_FILES'])
version_check = self.__compare_versions(VERSION, config["VERSION"])
file_check = self.__check_files(CURRENT_FILES, config["CURRENT_FILES"])

return version_check, file_check

@staticmethod
def __compare_versions(local_version: str, remote_version: str) -> tuple[str, str, str]:
def __compare_versions(
local_version: str, remote_version: str
) -> tuple[str, str, str]:
"""
Compares the local version with the remote version and returns a tuple containing a comparison result message,
a version information message, and a severity level.
Expand All @@ -52,9 +57,17 @@ def __compare_versions(local_version: str, remote_version: str) -> tuple[str, st
if local_version == remote_version:
return "Version is up to date.", f"Your Version: {local_version}", "INFO"
elif local_version > remote_version:
return "Version is ahead of the repository.", f"Your Version: {local_version}, Repository Version: {remote_version}", "WARNING"
return (
"Version is ahead of the repository.",
f"Your Version: {local_version}, Repository Version: {remote_version}",
"WARNING",
)
else:
return "Version is behind the repository.", f"Your Version: {local_version}, Repository Version: {remote_version}", "ERROR"
return (
"Version is behind the repository.",
f"Your Version: {local_version}, Repository Version: {remote_version}",
"ERROR",
)

@staticmethod
def __check_files(local_files: list, remote_files: list) -> tuple[str, str, str]:
Expand All @@ -71,9 +84,17 @@ def __check_files(local_files: list, remote_files: list) -> tuple[str, str, str]
"""
missing_files = set(remote_files) - set(local_files)
if not missing_files:
return "All files are present.", f"Your files: {local_files} contain all the files in the repository.", "INFO"
return (
"All files are present.",
f"Your files: {local_files} contain all the files in the repository.",
"INFO",
)
else:
return "You have missing files.", f"You are missing the following files: {missing_files}", "ERROR"
return (
"You have missing files.",
f"You are missing the following files: {missing_files}",
"ERROR",
)


class DebugCheck:
Expand All @@ -97,16 +118,26 @@ def SysInternal_Binaries(path: str) -> tuple[str, str]:
try:
contents = os.listdir(path)
log_debug.debug(contents)
if any(file.endswith('.ignore') for file in contents):
if any(file.endswith(".ignore") for file in contents):
return "A `.sys.ignore` file was found - Ignoring", "WARNING"
if any(file.endswith('.zip') for file in contents) and not any(file.endswith('.exe') for file in contents):
if any(file.endswith(".zip") for file in contents) and not any(
file.endswith(".exe") for file in contents
):
return "Only zip files - Missing EXE's due to no `ignore` file", "ERROR"
elif any(file.endswith('.zip') for file in contents) and any(file.endswith('.exe') for file in contents):
elif any(file.endswith(".zip") for file in contents) and any(
file.endswith(".exe") for file in contents
):
return "Both zip and exe files - All good", "INFO"
else:
return "SysInternal Binaries Not Found: Missing Files - Corruption detected", "ERROR"
return (
"SysInternal Binaries Not Found: Missing Files - Corruption detected",
"ERROR",
)
except FileNotFoundError:
return "SysInternal Binaries Not Found: Missing Directory- Corruption detected", "ERROR"
return (
"SysInternal Binaries Not Found: Missing Directory- Corruption detected",
"ERROR",
)
except Exception as e:
return f"An Unexpected error occurred: {e}", "ERROR"

Expand All @@ -118,8 +149,12 @@ def execution_policy() -> bool:
Returns:
bool: True if the execution policy is unrestricted, False otherwise.
"""
result = subprocess.run(['powershell', '-Command', 'Get-ExecutionPolicy'], capture_output=True, text=True)
return result.stdout.strip().lower() == 'unrestricted'
result = subprocess.run(
["powershell", "-Command", "Get-ExecutionPolicy"],
capture_output=True,
text=True,
)
return result.stdout.strip().lower() == "unrestricted"

@staticmethod
def cpu_info() -> tuple[str, str, str]:
Expand All @@ -129,7 +164,11 @@ def cpu_info() -> tuple[str, str, str]:
Returns:
tuple[str, str, str]: A tuple containing the CPU architecture, vendor ID, and model.
"""
return 'CPU Architecture: ' + platform.machine(), 'CPU Vendor Id: ' + platform.system(), 'CPU Model: ' + f"{platform.release()} {platform.version()}"
return (
"CPU Architecture: " + platform.machine(),
"CPU Vendor Id: " + platform.system(),
"CPU Model: " + f"{platform.release()} {platform.version()}",
)


def debug():
Expand Down Expand Up @@ -160,10 +199,14 @@ def debug():
# Check File integrity (Online)
if HealthCheck().get_online_config():
version_tuple, file_tuple = HealthCheck().get_online_config()
log_debug_funcs.get(version_tuple[2], log_debug.debug)("\n".join(version_tuple[0]).replace('\n', ''))
log_debug_funcs.get(file_tuple[2], log_debug.debug)("\n".join(file_tuple[0]).replace('\n', ''))
log_debug_funcs.get(version_tuple[2], log_debug.debug)(
"\n".join(version_tuple[0]).replace("\n", "")
)
log_debug_funcs.get(file_tuple[2], log_debug.debug)(
"\n".join(file_tuple[0]).replace("\n", "")
)
message, type = DebugCheck.SysInternal_Binaries("SysInternal_Suite")
log_debug_funcs.get(type, log_debug.debug)("\n".join(message).replace('\n', ''))
log_debug_funcs.get(type, log_debug.debug)("\n".join(message).replace("\n", ""))

# Check Admin
if Check().admin():
Expand Down Expand Up @@ -195,7 +238,9 @@ def debug():
log_debug.warning("Execution policy is not unrestricted")

# Get Python Version
log_debug.info(f"Python Version Used: {sys.version.split()[0]} - Recommended Version is: ~")
log_debug.info(
f"Python Version Used: {sys.version.split()[0]} - Recommended Version is: ~"
)

# Get Repo Path
log_debug.info(os.path.abspath(__file__).removesuffix("\\CODE\\_debug.py"))
Expand Down
30 changes: 21 additions & 9 deletions CODE/_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def __dev_checks(self) -> bool:
None
"""
checks = [
("Have you read the required contributing guidelines?", "../CONTRIBUTING.md"),
(
"Have you read the required contributing guidelines?",
"../CONTRIBUTING.md",
),
("Have you made files you don't want to be run start with '_'?", "."),
("Have you added the file to CODE dir?", "."),
("Have you added docstrings and comments?", "../CONTRIBUTING.md"),
Expand All @@ -79,8 +82,13 @@ def __dev_checks(self) -> bool:
return False

remind = False
if self.__prompt_user("Is the update a major or minor upgrade (non-patch update)?"):
if not self.__prompt_user("Did You Build the EXE with Advanced Installer?", "../Logicytics.aip"):
if self.__prompt_user(
"Is the update a major or minor upgrade (non-patch update)?"
):
if not self.__prompt_user(
"Did You Build the EXE with Advanced Installer?",
"../Logicytics.aip",
):
return False
else:
remind = True
Expand All @@ -92,9 +100,13 @@ def __dev_checks(self) -> bool:
return False

self.__update_json_file("config.json", files, "CURRENT_FILES")
self.__update_json_file("config.json",
input(f"Enter the new version of the project (Old version is {VERSION}):"),
"VERSION")
self.__update_json_file(
"config.json",
input(
f"Enter the new version of the project (Old version is {VERSION}):"
),
"VERSION",
)
print(
"Great Job! Please tick the box in the GitHub PR request for completing steps in --dev"
)
Expand Down Expand Up @@ -122,9 +134,9 @@ def run_dev(self):
test_files = []
for item in os.listdir("../TESTS"):
if (
item.lower().endswith(".py")
and item.lower() != "__init__.py"
and item.lower() != "test.py"
item.lower().endswith(".py")
and item.lower() != "__init__.py"
and item.lower() != "test.py"
):
full_path = os.path.abspath(os.path.join("../TESTS", item))
test_files.append(full_path)
Expand Down
1 change: 1 addition & 0 deletions CODE/_extra.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __lib_class import *

if __name__ == "__main__":
log = Log(debug=DEBUG, filename="../ACCESS/LOGS/DEBUG/DEBUG.LOG")
log_funcs = {
Expand Down
4 changes: 2 additions & 2 deletions CODE/_zipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __get_files_to_zip(path: str) -> list:
return [
f
for f in os.listdir(path)
if not f.endswith((".py", ".exe", ".bat", ".ps1")) and not f.startswith(
("config.", "SysInternal_Suite", "__pycache__"))
if not f.endswith((".py", ".exe", ".bat", ".ps1"))
and not f.startswith(("config.", "SysInternal_Suite", "__pycache__"))
]

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions CODE/sensitive_data_miner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shutil
from pathlib import Path
from __lib_class import *

log = Log(debug=DEBUG)
log_funcs = {
"INFO": log.info,
Expand Down
1 change: 1 addition & 0 deletions CODE/sys_internal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __lib_class import *

log = Log(debug=DEBUG)
log_funcs = {
"INFO": log.info,
Expand Down
3 changes: 1 addition & 2 deletions CODE/todo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
black .
--dev
Then update readme, wiki and contributing guidelines
Finally after all, create a pr, and a release, then the release should contain the commit history etc
Finally after all, create a pr, and a release, then the release should contain the commit history etc
1 change: 1 addition & 0 deletions CODE/wifi_stealer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __lib_class import *

log = Log(debug=DEBUG)
log_funcs = {
"INFO": log.info,
Expand Down

0 comments on commit 51336d3

Please sign in to comment.