Merge branch 'dev' into feature/openmetrics-implementation

This commit is contained in:
Silversthorn 2023-10-08 00:06:34 +02:00
commit 5947d4ebbf
8 changed files with 82 additions and 66 deletions

View File

@ -13,6 +13,8 @@
- 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))
- 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))
@ -25,6 +27,8 @@
- 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))
- 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
<br><br>

View File

@ -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

View File

@ -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
@ -45,6 +45,45 @@ 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 = {}
@ -172,45 +211,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
# **********************************************************************************

View File

@ -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
@ -330,6 +329,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 +451,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 +613,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

View File

@ -7,6 +7,7 @@ import json
import logging
import threading
import urllib.parse
from zoneinfo import ZoneInfoNotFoundError
import nh3
import requests
import tornado.web
@ -15,7 +16,6 @@ from tornado import iostream
# TZLocal is set as a hidden import on win pipeline
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

View File

@ -591,7 +591,9 @@
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false
});
setTimeout(function(){
getDirView();
}, 2000);
} else {
bootbox.alert("You must input a path before selecting this button");
}
@ -638,7 +640,9 @@
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false
});
setTimeout(function(){
getDirView();
}, 2000);
} else {
bootbox.alert("You must input a path before selecting this button");
}

View File

@ -826,8 +826,9 @@
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false
});
console.log("CALLING DIR")
setTimeout(function(){
getDirView();
}, 2000);
} else {
bootbox.alert("You must input a path before selecting this button");
}
@ -843,8 +844,9 @@
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false
});
console.log("CALLING DIR")
setTimeout(function(){
getDirView();
}, 2000);
});
var upload = false;
var file;

View File

@ -1,23 +1,22 @@
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
orjson==3.8.12
tzlocal==5.1
jsonschema==4.19.1
orjson==3.9.7
prometheus-client==0.17.1