Skip to content

Commit

Permalink
Quick update, Fixed bug
Browse files Browse the repository at this point in the history
Made sure everything works fine, made minor updates on spelling and grammar and Licensing on md files,
Also fixed bug in _health.py where --update flag incorrectly decoded the command, which was parsed incorrectly, now its fixed, and added extra bug checks
Finally fixed minor bugs in the dev menu
  • Loading branch information
DefinetlyNotAI committed Nov 8, 2024
1 parent b7a5a58 commit bd3848e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 83 deletions.
3 changes: 2 additions & 1 deletion CODE/Logicytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion CODE/__lib_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
93 changes: 24 additions & 69 deletions CODE/_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
18 changes: 14 additions & 4 deletions CODE/_health.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import shutil
from typing import Tuple

from __lib_class import *


Expand Down Expand Up @@ -28,19 +30,27 @@ 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.
This function navigates to the parent directory, pulls the latest changes using Git,
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"
2 changes: 1 addition & 1 deletion CODE/config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 4 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 🛠️

Expand Down Expand Up @@ -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 📝

Expand Down

0 comments on commit bd3848e

Please sign in to comment.