diff --git a/CODE/Logicytics.py b/CODE/Logicytics.py index 3ac5a30..da3d78e 100644 --- a/CODE/Logicytics.py +++ b/CODE/Logicytics.py @@ -73,7 +73,8 @@ def special_run(file_path: str): if action == "update": log.info("Updating...") - log.info(update()) + message, log_type = update() + log.string(message, log_type) log.info("Update complete!") input("Press Enter to exit...") exit(0) diff --git a/CODE/__lib_class.py b/CODE/__lib_class.py index a534f3f..a0ecd0f 100644 --- a/CODE/__lib_class.py +++ b/CODE/__lib_class.py @@ -92,7 +92,7 @@ def __parse_arguments() -> tuple[argparse.Namespace, argparse.ArgumentParser]: parser.add_argument( "--update", action="store_true", - help="Update Logicytics from GitHub - Use on your own device only -.", + help="Update Logicytics from GitHub, only if you have git and the project was downloaded via git - Use on your own device only -.", ) parser.add_argument( "--extra", diff --git a/CODE/_dev.py b/CODE/_dev.py index e81e9ba..732ef60 100644 --- a/CODE/_dev.py +++ b/CODE/_dev.py @@ -30,7 +30,7 @@ def __update_json_file(filename: str, new_data: list | str, key: str) -> None: log_dev.error(f"An error occurred: {e}") @staticmethod - def __prompt_user(question: str, file_to_open: str = None) -> bool: + def __prompt_user(question: str, file_to_open: str = None, special: bool = False) -> bool: """ Prompts the user with a question and optionally opens a file if the answer is not 'yes'. Args: @@ -44,106 +44,61 @@ def __prompt_user(question: str, file_to_open: str = None) -> bool: if answer.lower() != "yes": if file_to_open: subprocess.run(["start", file_to_open], shell=True) - print( - "Please ensure you fix the issues/problem and try again with the checklist." - ) + if not special: + print( + "Please ensure you fix the issues/problem and try again with the checklist." + ) return False return True except Exception as e: log_dev.error(e) - def __dev_checks(self) -> bool: + def dev_checks(self) -> str | None: """ Performs a series of checks to ensure that the developer has followed the required guidelines and best practices. - This function prompts the developer with a series of questions to ensure that they have followed the required - contributing guidelines, added files with a specific naming convention, added the file to the CODE directory, - added docstrings and comments to their code, tested their code, ensured that each file contains only one feature, - and has included the proper flags in their code. Returns: - None + bool: True if all checks pass, otherwise False. """ + Actions.mkdir() 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"), ("Is each file containing no more than 1 feature?", "../CONTRIBUTING.md"), - ( - "Have you NOT modified __wrapper__.py without authorization?", - "Logicytics.py", - ), + ("Have you NOT modified __wrapper__.py without authorization?", "Logicytics.py"), ] try: for question, file_to_open in checks: if not self.__prompt_user(question, file_to_open): - return False + return "Fix the issues and try again with the checklist." - remind = False - if self.__prompt_user( - "If the update is a major or minor upgrade (non-patch update) answer `yes`?" - ): - if not self.__prompt_user( - "Did You Build the EXE with Advanced Installer?", - "../Logicytics.aip", - ): - return False - else: - remind = True + remind = self.__prompt_user( + "If the update is a major or minor upgrade (non-patch update) answer `yes`?", special=True + ) + if remind: + remind = not self.__prompt_user("Did You Build the EXE with Advanced Installer?", "../Logicytics.aip") files = Actions.check_current_files(".") print(files) if not self.__prompt_user("Does the list above include your added files?"): - log_dev.error("Something went wrong! Please contact support.") - return False + return "Something went wrong! Please contact support." 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}):" - ), + 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" - ) + print("Great Job! Please tick the box in the GitHub PR request for completing steps in --dev") if remind: print("Remember to upload the EXE files on the PR!") - return True + return None except Exception as e: - log_dev.error(e) - return False - - def run_dev(self): - """ - Executes the development checks and runs the test files. - - This function performs the following steps: - 1. Creates necessary directories. - 2. Executes development checks to ensure guidelines and best practices are followed. - 3. Collects and runs all Python test files in the `../TESTS` directory, excluding `__init__.py` and `test.py`. - - Returns: - None - """ - Actions.mkdir() - if self.__dev_checks(): - test_files = [] - for item in os.listdir("../TESTS"): - if ( - 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) - log_dev.info(f"Found test file: {item} - Full path: {full_path}") - for item in test_files: - log_dev.info(Actions.run_command(f"python {item}")) + return str(e) log_dev = Log({"log_level": DEBUG}) -Dev().run_dev() +message = Dev().dev_checks() +if message is not None: + log_dev.error(message) diff --git a/CODE/_health.py b/CODE/_health.py index d52bf90..0bc750c 100644 --- a/CODE/_health.py +++ b/CODE/_health.py @@ -1,4 +1,6 @@ import shutil +from typing import Tuple + from __lib_class import * @@ -28,7 +30,7 @@ def backup(directory: str, name: str) -> None: shutil.move(f"{name}.zip", "../ACCESS/BACKUP") -def update() -> str: +def update() -> tuple[str, str]: """ Updates the repository by pulling the latest changes from the remote repository. @@ -36,11 +38,19 @@ def update() -> str: and then returns to the current working directory. Returns: - None + str: The output from the git pull command. """ + # Check if git command is available + if subprocess.run(["git", "--version"], capture_output=True).returncode != 0: + return "Git is not installed or not available in the PATH.", "error" + + # Check if the project is a git repository + if not os.path.exists(os.path.join(os.getcwd(), ".git")): + return "This project is not a git repository. The update flag uses git.", "error" + current_dir = os.getcwd() parent_dir = os.path.dirname(current_dir) os.chdir(parent_dir) - output = subprocess.run(["git", "pull"]).stdout.decode() + output = subprocess.run(["git", "pull"], capture_output=True).stdout.decode() os.chdir(current_dir) - return output + return output, "info" diff --git a/CODE/config.json b/CODE/config.json index fcc1fdd..2c171e6 100644 --- a/CODE/config.json +++ b/CODE/config.json @@ -1,7 +1,7 @@ { "ipgeolocation.io API KEY": "OPTIONAL - ADD A KEY", "Log Level Debug?": false, - "VERSION": "2.3.5", + "VERSION": "2.3.6", "CURRENT_FILES": [ "browser_miner.ps1", "driverquery+sysinfo.py", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b260ce2..00e7f28 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ restrictions: ## Issues assignment -I will be looking at the open issues, analyze them, and provide guidance on how to proceed. +I will be looking at the open issues, analyse them, and provide guidance on how to proceed. Issues can be assigned to anyone other than me and contributors are welcome to participate in the discussion and provide their input on how to best solve the issue, @@ -48,7 +48,7 @@ leave core files alone. ## Guidelines for Modifications 📃 When making modifications to the Logicytics project, -please adhere to the following guidelines on the WiKi page. +please adhere to the following guidelines on the Wiki page. ## Issues and labels 🛠️ @@ -100,13 +100,10 @@ Please adhere to the coding guidelines used throughout the project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). -View the WiKi for more information on how to write pull requests. +View the Wiki for more information on how to write pull requests. **IMPORTANT**: By submitting a patch, you agree to allow the project owners to -license your work under the terms of the [MIT License](https://github.com/DefinetlyNotAI/Logicytics/blob/main/LICENSE) ( -if it -includes code changes) and under the terms of the -[Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/). +license your work under the terms of the [License](https://github.com/DefinetlyNotAI/Logicytics/blob/main/LICENSE) ## License 📝