mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-31 12:56:11 +01:00
Merge branch 'bug/tz-fallback' into 'dev'
Add fallback for tz not being found See merge request crafty-controller/crafty-4!331
This commit is contained in:
commit
6fea0dfc50
@ -38,18 +38,28 @@ class Import3:
|
||||
# If there is only one user to import json needs to call the data differently
|
||||
if isinstance(json_data, list):
|
||||
for user in json_data:
|
||||
HelperUsers.add_rawpass_user(user["username"], user["password"])
|
||||
Console.info(f"Imported user {user['username']} from Crafty 3")
|
||||
logger.info(f"Imported user {user['username']} from Crafty 3")
|
||||
if str(user["username"]).lower() != "admin":
|
||||
HelperUsers.add_rawpass_user(user["username"], user["password"])
|
||||
Console.info(f"Imported user {user['username']} from Crafty 3")
|
||||
logger.info(f"Imported user {user['username']} from Crafty 3")
|
||||
else:
|
||||
logger.info("Cannot create duplicate Admin account...skipping.")
|
||||
else:
|
||||
Console.info(
|
||||
"There is only one user detected. "
|
||||
"Cannot create duplicate Admin account."
|
||||
)
|
||||
logger.info(
|
||||
"There is only one user detected. "
|
||||
"Cannot create duplicate Admin account."
|
||||
)
|
||||
if str(json_data["username"]).lower() != "admin":
|
||||
HelperUsers.add_rawpass_user(
|
||||
json_data["username"], json_data["password"]
|
||||
)
|
||||
Console.info(f"Imported user {json_data['username']} from Crafty 3")
|
||||
logger.info(f"Imported user {json_data['username']} from Crafty 3")
|
||||
else:
|
||||
Console.info(
|
||||
"There is only one user detected. "
|
||||
"Cannot create duplicate Admin account."
|
||||
)
|
||||
logger.info(
|
||||
"There is only one user detected. "
|
||||
"Cannot create duplicate Admin account."
|
||||
)
|
||||
|
||||
def import_servers(self, json_data, controller):
|
||||
# If there is only one server to import json needs to call the data differently
|
||||
|
@ -9,20 +9,21 @@ 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.controllers.crafty_perms_controller import CraftyPermsController
|
||||
from app.classes.controllers.management_controller import ManagementController
|
||||
from app.classes.controllers.users_controller import UsersController
|
||||
from app.classes.controllers.roles_controller import RolesController
|
||||
from app.classes.controllers.server_perms_controller import ServerPermsController
|
||||
from app.classes.controllers.servers_controller import ServersController
|
||||
from app.classes.models.server_permissions import EnumPermissionsServer
|
||||
from app.classes.shared.main_models import DatabaseShortcuts
|
||||
from app.classes.models.users import HelperUsers
|
||||
from app.classes.models.roles import HelperRoles
|
||||
from app.classes.models.management import HelpersManagement
|
||||
from app.classes.models.servers import HelperServers
|
||||
from app.classes.controllers.crafty_perms_controller import CraftyPermsController
|
||||
from app.classes.controllers.management_controller import ManagementController
|
||||
from app.classes.controllers.users_controller import UsersController
|
||||
from app.classes.controllers.roles_controller import RolesController
|
||||
from app.classes.controllers.server_perms_controller import ServerPermsController
|
||||
from app.classes.controllers.servers_controller import ServersController
|
||||
from app.classes.shared.authentication import Authentication
|
||||
from app.classes.shared.console import Console
|
||||
from app.classes.shared.helpers import Helpers
|
||||
@ -57,7 +58,13 @@ class Controller:
|
||||
self.users: UsersController = UsersController(
|
||||
self.helper, self.users_helper, self.authentication
|
||||
)
|
||||
tz = get_localzone()
|
||||
try:
|
||||
tz = get_localzone()
|
||||
except ZoneInfoNotFoundError:
|
||||
logger.error(
|
||||
"Could not capture time zone from system. Falling back to Europe/London"
|
||||
)
|
||||
tz = "Europe/London"
|
||||
self.support_scheduler: BackgroundScheduler = BackgroundScheduler(
|
||||
timezone=str(tz)
|
||||
)
|
||||
|
@ -13,6 +13,7 @@ import tempfile
|
||||
|
||||
# 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 apscheduler.jobstores.base import JobLookupError
|
||||
|
||||
@ -125,7 +126,13 @@ class ServerInstance:
|
||||
self.stats = stats
|
||||
self.server_object = HelperServers.get_server_obj(self.server_id)
|
||||
self.stats_helper = HelperServerStats(self.server_id)
|
||||
tz = get_localzone()
|
||||
try:
|
||||
tz = get_localzone()
|
||||
except ZoneInfoNotFoundError:
|
||||
logger.error(
|
||||
"Could not capture time zone from system. Falling back to Europe/London"
|
||||
)
|
||||
tz = "Europe/London"
|
||||
self.server_scheduler = BackgroundScheduler(timezone=str(tz))
|
||||
self.server_scheduler.start()
|
||||
self.backup_thread = threading.Thread(
|
||||
|
@ -4,14 +4,16 @@ import logging
|
||||
import threading
|
||||
import asyncio
|
||||
import datetime
|
||||
|
||||
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
|
||||
from app.classes.controllers.users_controller import UsersController
|
||||
|
||||
from app.classes.models.management import HelpersManagement
|
||||
from app.classes.models.users import HelperUsers
|
||||
from app.classes.controllers.users_controller import UsersController
|
||||
from app.classes.shared.console import Console
|
||||
from app.classes.shared.helpers import Helpers
|
||||
from app.classes.shared.main_controller import Controller
|
||||
@ -41,8 +43,13 @@ class TasksManager:
|
||||
self.helper: Helpers = helper
|
||||
self.controller: Controller = controller
|
||||
self.tornado: Webserver = Webserver(helper, controller, self)
|
||||
|
||||
self.tz = get_localzone()
|
||||
try:
|
||||
self.tz = get_localzone()
|
||||
except ZoneInfoNotFoundError:
|
||||
logger.error(
|
||||
"Could not capture time zone from system. Falling back to Europe/London"
|
||||
)
|
||||
self.tz = "Europe/London"
|
||||
self.scheduler = BackgroundScheduler(timezone=str(self.tz))
|
||||
|
||||
self.users_controller: UsersController = self.controller.users
|
||||
|
@ -15,13 +15,14 @@ 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 croniter import croniter
|
||||
from app.classes.controllers.roles_controller import RolesController
|
||||
|
||||
from app.classes.models.servers import Servers
|
||||
from app.classes.models.server_permissions import EnumPermissionsServer
|
||||
from app.classes.models.crafty_permissions import EnumPermissionsCrafty
|
||||
from app.classes.models.management import HelpersManagement
|
||||
from app.classes.controllers.roles_controller import RolesController
|
||||
from app.classes.shared.helpers import Helpers
|
||||
from app.classes.shared.main_models import DatabaseShortcuts
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
@ -276,10 +277,18 @@ class PanelHandler(BaseHandler):
|
||||
user_order.remove(server_id)
|
||||
defined_servers = page_servers
|
||||
|
||||
try:
|
||||
tz = get_localzone()
|
||||
except ZoneInfoNotFoundError:
|
||||
logger.error(
|
||||
"Could not capture time zone from system. Falling back to Europe/London"
|
||||
)
|
||||
tz = "Europe/London"
|
||||
|
||||
page_data: t.Dict[str, t.Any] = {
|
||||
# todo: make this actually pull and compare version data
|
||||
"update_available": False,
|
||||
"serverTZ": get_localzone(),
|
||||
"serverTZ": tz,
|
||||
"version_data": self.helper.get_version_string(),
|
||||
"user_data": exec_user,
|
||||
"user_role": exec_user_role,
|
||||
|
Loading…
x
Reference in New Issue
Block a user