From 7a410a2b0ef9e0e4266ade36d80f70137b0c71c8 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Thu, 5 Oct 2023 17:48:55 -0400 Subject: [PATCH 01/12] Fix bug reaction schedule could be child of parent --- app/classes/shared/tasks.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index c89be9d8..aac4d33a 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -330,6 +330,8 @@ class TasksManager: # Check to see if it's enabled and is not a chain reaction. if job_data["enabled"] and job_data["interval_type"] != "reaction": + # Lets make sure this can not be mistaken for a reaction + job_data["parent"] = None new_job = "error" if job_data["cron_string"] != "": try: @@ -450,7 +452,10 @@ class TasksManager: def update_job(self, sch_id, job_data): # Checks to make sure some doofus didn't actually make the newly # created task a child of itself. - if str(job_data.get("parent")) == str(sch_id): + if ( + str(job_data.get("parent")) == str(sch_id) + or job_data["interval_type"] != "reaction" + ): job_data["parent"] = None HelpersManagement.update_scheduled_task(sch_id, job_data) @@ -609,7 +614,10 @@ class TasksManager: ): # event job ID's are strings so we need to look at # this as the same data type. - if str(schedule.parent) == str(event.job_id): + if ( + str(schedule.parent) == str(event.job_id) + and schedule.interval_type == "reaction" + ): if schedule.enabled: delaytime = datetime.datetime.now() + datetime.timedelta( seconds=schedule.delay From 5525413724eddc437adca44c3d9f7b657cbdcacb Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 6 Oct 2023 13:33:56 -0400 Subject: [PATCH 02/12] Set timeout before calling dir function --- app/frontend/templates/server/bedrock_wizard.html | 8 ++++++-- app/frontend/templates/server/wizard.html | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/frontend/templates/server/bedrock_wizard.html b/app/frontend/templates/server/bedrock_wizard.html index 4193c6d7..823a4585 100644 --- a/app/frontend/templates/server/bedrock_wizard.html +++ b/app/frontend/templates/server/bedrock_wizard.html @@ -591,7 +591,9 @@ message: '

Please wait while we gather your files...

', closeButton: false }); - getDirView(); + setTimeout(function(){ + getDirView(); + }, 2000); } else { bootbox.alert("You must input a path before selecting this button"); } @@ -638,7 +640,9 @@ message: '

Please wait while we gather your files...

', closeButton: false }); - getDirView(); + setTimeout(function(){ + getDirView(); + }, 2000); } else { bootbox.alert("You must input a path before selecting this button"); } diff --git a/app/frontend/templates/server/wizard.html b/app/frontend/templates/server/wizard.html index 850bf505..fbc89f50 100644 --- a/app/frontend/templates/server/wizard.html +++ b/app/frontend/templates/server/wizard.html @@ -827,7 +827,9 @@ closeButton: false }); console.log("CALLING DIR") - getDirView(); + setTimeout(function(){ + getDirView(); + }, 2000); } else { bootbox.alert("You must input a path before selecting this button"); } @@ -844,7 +846,9 @@ closeButton: false }); console.log("CALLING DIR") - getDirView(); + setTimeout(function(){ + getDirView(); + }, 2000); }); var upload = false; var file; From 4f994ce211fbef65e5e13b25cf7329a5b0469024 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 6 Oct 2023 14:24:55 -0400 Subject: [PATCH 03/12] Remove un-needed console log --- app/frontend/templates/server/wizard.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/frontend/templates/server/wizard.html b/app/frontend/templates/server/wizard.html index fbc89f50..bb5fc175 100644 --- a/app/frontend/templates/server/wizard.html +++ b/app/frontend/templates/server/wizard.html @@ -826,7 +826,6 @@ message: '

Please wait while we gather your files...

', closeButton: false }); - console.log("CALLING DIR") setTimeout(function(){ getDirView(); }, 2000); @@ -845,7 +844,6 @@ message: '

Please wait while we gather your files...

', closeButton: false }); - console.log("CALLING DIR") setTimeout(function(){ getDirView(); }, 2000); From bd76366f3bf8263bc284ae32beb3c3e2fdaef8dc Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 6 Oct 2023 15:48:05 -0400 Subject: [PATCH 04/12] Bump orjson to 3.9.7 for python 3.12 support --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1967c40e..305466de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,4 @@ termcolor==1.1 tornado==6.3.3 tzlocal==4.0 jsonschema==4.5.1 -orjson==3.8.12 +orjson==3.9.7 From 87d81f3ad7f5c847603c9ecca56314ca9554fad3 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 7 Oct 2023 16:11:03 +0100 Subject: [PATCH 05/12] Update changelog !636 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4b0a708..a3a721b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix public status page not updating #255 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/615)) - Fix service worker vulrn and CQ raised by SonarQ ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/631)) - Fix Backup Restore/Schedules, Backup button function on `remote-comms2` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/634)) +- Fix bug where a reaction loop could be created, but would be cut short by an error when the loop occurred ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/636)) ### Refactor - Consolidate remaining frontend functions into API V2, and remove ajax internal API ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/585)) - Replace bleach with nh3 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/628)) From ca430f991b1a63d44bb82b87f3747e472f5487be Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 7 Oct 2023 16:48:27 +0100 Subject: [PATCH 06/12] Update changelog !637 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 266ec6bf..989d3b67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fix public status page not updating #255 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/615)) - Fix service worker vulrn and CQ raised by SonarQ ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/631)) - Fix Backup Restore/Schedules, Backup button function on `remote-comms2` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/634)) +- Add a wait to the call for the directory so we can make sure the wait dialogue has time to show up first ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/637)) ### Refactor - Consolidate remaining frontend functions into API V2, and remove ajax internal API ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/585)) - Replace bleach with nh3 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/628)) From f42f4cf2b688d34c45361506cc940d712f75773f Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 7 Oct 2023 11:59:46 -0400 Subject: [PATCH 07/12] Bump multiple dep versions Refactor zoneinfonotfounderror --- app/classes/shared/main_controller.py | 2 +- app/classes/shared/server.py | 2 +- app/classes/shared/tasks.py | 3 +-- app/classes/web/panel_handler.py | 2 +- requirements.txt | 25 ++++++++++++------------- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 541e45ad..23586696 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -8,11 +8,11 @@ import time import json import logging import threading +from zoneinfo import ZoneInfoNotFoundError from peewee import DoesNotExist # TZLocal is set as a hidden import on win pipeline from tzlocal import get_localzone -from tzlocal.utils import ZoneInfoNotFoundError from apscheduler.schedulers.background import BackgroundScheduler from app.classes.models.server_permissions import EnumPermissionsServer diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 79dc0f22..0747ff55 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -16,8 +16,8 @@ import json from zoneinfo import ZoneInfo # TZLocal is set as a hidden import on win pipeline +from zoneinfo import ZoneInfoNotFoundError from tzlocal import get_localzone -from tzlocal.utils import ZoneInfoNotFoundError from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.jobstores.base import JobLookupError, ConflictingIdError diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index c89be9d8..76f20119 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -5,9 +5,8 @@ import threading import asyncio import datetime import json - +from zoneinfo import ZoneInfoNotFoundError from tzlocal import get_localzone -from tzlocal.utils import ZoneInfoNotFoundError from apscheduler.events import EVENT_JOB_EXECUTED from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 58b6056c..7a0afd32 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -14,8 +14,8 @@ import tornado.escape from tornado import iostream # TZLocal is set as a hidden import on win pipeline +from zoneinfo import ZoneInfoNotFoundError from tzlocal import get_localzone -from tzlocal.utils import ZoneInfoNotFoundError from app.classes.models.servers import Servers from app.classes.models.server_permissions import EnumPermissionsServer diff --git a/requirements.txt b/requirements.txt index 1967c40e..341a1d79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,21 @@ -apscheduler==3.8.1 -argon2-cffi==21.3 +apscheduler==3.10.4 +argon2-cffi==23.1.0 cached_property==1.5.2 -colorama==0.4 -croniter==1.3.5 -cryptography==41.0.3 -libgravatar==1.0.0 +colorama==0.4.6 +croniter==1.4.1 +cryptography==41.0.4 +libgravatar==1.0.4 nh3==0.2.14 -packaging==23.1 -peewee==3.13 -pexpect==4.8 +packaging==23.2 +peewee==3.16.3 psutil==5.9.5 pyOpenSSL==23.2.0 -pyjwt==2.4.0 +pyjwt==2.8.0 PyYAML==6.0.1 -requests==2.31 +requests==2.31.0 termcolor==1.1 tornado==6.3.3 -tzlocal==4.0 -jsonschema==4.5.1 +tzlocal==5.1 +jsonschema==4.19.1 orjson==3.8.12 From c3c00dabc251071f13c5a87742f2204cef2fde77 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 7 Oct 2023 17:05:59 +0100 Subject: [PATCH 08/12] Update changelog !638 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cdb181c..d297bce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Use `Jar` class naming for jar refresh to make room for steamCMD naming in the future ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/630)) - Improve ui visibility of Build Wizard selection tabs ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/633)) - Add additional logging for server bootstrap & moves unnecessary logging to `debug` for improved log clarity ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/635)) +- Bump orjson to 3.9.7 for python 3.12 support ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/638)) ### Lang TBD

From 42bdf2994d98d904ad989e1963fbe92f072023b4 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 7 Oct 2023 13:06:26 -0400 Subject: [PATCH 09/12] Move callback to unbound --- app/classes/shared/server.py | 75 +++++++++++++++++------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 0747ff55..ccd09605 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -41,7 +41,43 @@ with redirect_stderr(NullWriter()): logger = logging.getLogger(__name__) +def callback(called_func): + # Usage of @callback on method + # definition to run a webhook check + # on method completion + def wrapper(*args, **kwargs): + res = None + logger.debug("Checking for callbacks") + try: + res = called_func(*args, **kwargs) + finally: + events = WebhookFactory.get_monitored_events() + if called_func.__name__ in events: + server_webhooks = HelpersWebhooks.get_webhooks_by_server( + args[0].server_id, True + ) + for swebhook in server_webhooks: + if called_func.__name__ in str(swebhook.trigger).split(","): + logger.info( + f"Found callback for event {called_func.__name__}" + f" for server {args[0].server_id}" + ) + webhook = HelpersWebhooks.get_webhook_by_id(swebhook.id) + webhook_provider = WebhookFactory.create_provider( + webhook["webhook_type"] + ) + if res is not False and swebhook.enabled: + webhook_provider.send( + bot_name=webhook["bot_name"], + server_name=args[0].name, + title=webhook["name"], + url=webhook["url"], + message=webhook["body"], + color=webhook["color"], + ) + return res + return wrapper class ServerOutBuf: lines = {} @@ -166,45 +202,6 @@ class ServerInstance: self.stats_helper.server_crash_reset() self.stats_helper.set_update(False) - @staticmethod - def callback(called_func): - # Usage of @callback on method - # definition to run a webhook check - # on method completion - def wrapper(*args, **kwargs): - res = None - logger.debug("Checking for callbacks") - try: - res = called_func(*args, **kwargs) - finally: - events = WebhookFactory.get_monitored_events() - if called_func.__name__ in events: - server_webhooks = HelpersWebhooks.get_webhooks_by_server( - args[0].server_id, True - ) - for swebhook in server_webhooks: - if called_func.__name__ in str(swebhook.trigger).split(","): - logger.info( - f"Found callback for event {called_func.__name__}" - f" for server {args[0].server_id}" - ) - webhook = HelpersWebhooks.get_webhook_by_id(swebhook.id) - webhook_provider = WebhookFactory.create_provider( - webhook["webhook_type"] - ) - if res is not False and swebhook.enabled: - webhook_provider.send( - bot_name=webhook["bot_name"], - server_name=args[0].name, - title=webhook["name"], - url=webhook["url"], - message=webhook["body"], - color=webhook["color"], - ) - return res - - return wrapper - # ********************************************************************************** # Minecraft Server Management # ********************************************************************************** From 882f241181d8fc254d62efd04f1b6fc41f9d1783 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 7 Oct 2023 13:13:35 -0400 Subject: [PATCH 10/12] Appease black --- app/classes/shared/server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index ccd09605..a8471982 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -41,6 +41,7 @@ with redirect_stderr(NullWriter()): logger = logging.getLogger(__name__) + def callback(called_func): # Usage of @callback on method # definition to run a webhook check @@ -78,6 +79,8 @@ def callback(called_func): return res return wrapper + + class ServerOutBuf: lines = {} From 77c7264f2b6c187e263de6bdd80a45878542a937 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 7 Oct 2023 18:32:03 +0100 Subject: [PATCH 11/12] Update changelog !639 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d297bce1..a572d201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Improve ui visibility of Build Wizard selection tabs ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/633)) - Add additional logging for server bootstrap & moves unnecessary logging to `debug` for improved log clarity ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/635)) - Bump orjson to 3.9.7 for python 3.12 support ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/638)) +- Bump all Crafty required python dependancies, maintaining minimum 3.9 support ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/639)) ### Lang TBD

From 529b3a159cfa1c7e69b27f8c4e1c4d8a1362b498 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 7 Oct 2023 13:55:36 -0400 Subject: [PATCH 12/12] Appease the linter --- app/classes/web/panel_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 7a0afd32..e1d21f03 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -7,6 +7,7 @@ import json import logging import threading import urllib.parse +from zoneinfo import ZoneInfoNotFoundError import nh3 import requests import tornado.web @@ -14,7 +15,6 @@ import tornado.escape from tornado import iostream # TZLocal is set as a hidden import on win pipeline -from zoneinfo import ZoneInfoNotFoundError from tzlocal import get_localzone from app.classes.models.servers import Servers