mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'tweak/fix-imports' into 'dev'
Tidy imports & dep auto-installer See merge request crafty-controller/crafty-commander!199
This commit is contained in:
commit
4cc617fd0d
@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
from app.classes.models.crafty_permissions import crafty_permissions, Enum_Permissions_Crafty
|
||||
from app.classes.models.crafty_permissions import crafty_permissions, Enum_Permissions_Crafty
|
||||
from app.classes.models.users import ApiKeys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -3,7 +3,6 @@ import logging
|
||||
from app.classes.models.roles import roles_helper
|
||||
from app.classes.models.server_permissions import server_permissions
|
||||
from app.classes.models.users import users_helper
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -4,7 +4,6 @@ from app.classes.models.server_permissions import server_permissions, Enum_Perm
|
||||
from app.classes.models.users import users_helper, ApiKeys
|
||||
from app.classes.models.roles import roles_helper
|
||||
from app.classes.models.servers import servers_helper
|
||||
|
||||
from app.classes.shared.main_models import db_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -2,15 +2,13 @@ import os
|
||||
import logging
|
||||
import json
|
||||
|
||||
from app.classes.controllers.roles_controller import Roles_Controller
|
||||
from app.classes.models.servers import servers_helper
|
||||
from app.classes.models.users import users_helper, ApiKeys
|
||||
from app.classes.models.server_permissions import server_permissions, Enum_Permissions_Server
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.main_models import db_helper
|
||||
|
||||
from app.classes.controllers.roles_controller import Roles_Controller
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Servers_Controller:
|
||||
|
@ -1,11 +1,10 @@
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.authentication import authentication
|
||||
|
||||
from app.classes.models.users import users_helper
|
||||
from app.classes.models.crafty_permissions import crafty_permissions, Enum_Permissions_Crafty
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.authentication import authentication
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -8,12 +8,11 @@ import logging.config
|
||||
import uuid
|
||||
import random
|
||||
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.minecraft.bedrock_ping import BedrockPing
|
||||
from app.classes.shared.console import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Server:
|
||||
def __init__(self, data):
|
||||
self.description = data.get('description')
|
||||
|
@ -1,4 +1,3 @@
|
||||
import sys
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
@ -6,11 +5,10 @@ import shutil
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.controllers.servers_controller import Servers_Controller
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.models.server_permissions import server_permissions
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -18,10 +16,7 @@ try:
|
||||
import requests
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
logger.critical(f"Import Error: Unable to load {err.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {err.name} module")
|
||||
sys.exit(1)
|
||||
|
||||
helper.auto_installer_fix(err)
|
||||
|
||||
class ServerJars:
|
||||
|
||||
|
@ -4,15 +4,13 @@ import datetime
|
||||
import base64
|
||||
import psutil
|
||||
|
||||
from app.classes.models.management import Host_Stats
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.models.servers import servers_helper
|
||||
from app.classes.minecraft.mc_ping import ping
|
||||
from app.classes.models.management import Host_Stats
|
||||
from app.classes.models.servers import servers_helper
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Stats:
|
||||
|
||||
def __init__(self, controller):
|
||||
|
@ -1,26 +1,20 @@
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.permission_helper import permission_helper
|
||||
|
||||
from app.classes.models.users import Users, ApiKeys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, ForeignKeyField, CharField, IntegerField, DoesNotExist
|
||||
from enum import Enum
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -1,31 +1,24 @@
|
||||
import sys
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.main_models import db_helper
|
||||
|
||||
from app.classes.models.users import Users, users_helper
|
||||
from app.classes.models.servers import Servers
|
||||
from app.classes.models.server_permissions import server_permissions
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.main_models import db_helper
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, ForeignKeyField, CharField, IntegerField, DateTimeField, FloatField, TextField, AutoField, BooleanField
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -1,24 +1,19 @@
|
||||
import sys
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, CharField, DoesNotExist, AutoField, DateTimeField
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -1,33 +1,25 @@
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.permission_helper import permission_helper
|
||||
|
||||
from app.classes.models.servers import Servers
|
||||
from app.classes.models.roles import Roles
|
||||
from app.classes.models.users import User_Roles, users_helper, ApiKeys, Users
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.permission_helper import permission_helper
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, ForeignKeyField, CharField, CompositeKey, JOIN
|
||||
from enum import Enum
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
||||
#************************************************************************************************
|
||||
# Role Servers Class
|
||||
#************************************************************************************************
|
||||
|
@ -1,24 +1,19 @@
|
||||
import sys
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.main_models import db_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, ForeignKeyField, CharField, AutoField, DateTimeField, BooleanField, IntegerField, FloatField
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -1,27 +1,21 @@
|
||||
import sys
|
||||
import logging
|
||||
import datetime
|
||||
from typing import Optional, Union
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
|
||||
from app.classes.models.roles import Roles, roles_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
try:
|
||||
from peewee import SqliteDatabase, Model, ForeignKeyField, CharField, AutoField, DateTimeField, BooleanField, CompositeKey, DoesNotExist, JOIN
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -2,14 +2,17 @@ import logging
|
||||
import time
|
||||
from typing import Optional, Dict, Any, Tuple
|
||||
|
||||
import jwt
|
||||
from jwt import PyJWTError
|
||||
|
||||
from app.classes.models.users import users_helper, ApiKeys
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
try:
|
||||
import jwt
|
||||
from jwt import PyJWTError
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Authentication:
|
||||
def __init__(self):
|
||||
|
@ -6,10 +6,10 @@ import logging
|
||||
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class MainPrompt(cmd.Cmd):
|
||||
|
||||
def __init__(self, tasks_manager, migration_manager):
|
||||
|
@ -2,18 +2,16 @@ import datetime
|
||||
import logging
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
try:
|
||||
from colorama import init
|
||||
from termcolor import colored
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
print(f"Import Error: Unable to load {e.name} module")
|
||||
from app.classes.shared.installer import installer
|
||||
installer.do_install()
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Console:
|
||||
|
||||
|
@ -1,21 +1,11 @@
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import logging
|
||||
import pathlib
|
||||
|
||||
from app.classes.shared.console import console
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
logger.critical(f"Import Error: Unable to load {err.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {err.name} module")
|
||||
sys.exit(1)
|
||||
|
||||
class FileHelpers:
|
||||
allowed_quotes = [
|
||||
"\"",
|
||||
|
@ -18,23 +18,23 @@ from datetime import datetime
|
||||
from socket import gethostname
|
||||
from contextlib import suppress
|
||||
import psutil
|
||||
from requests import get
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.installer import installer
|
||||
from app.classes.shared.file_helpers import file_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
try:
|
||||
import requests
|
||||
from requests import get
|
||||
from OpenSSL import crypto
|
||||
from argon2 import PasswordHasher
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
logger.critical(f"Import Error: Unable to load {err.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {err.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(err)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Helpers:
|
||||
allowed_quotes = [
|
||||
@ -61,6 +61,12 @@ class Helpers:
|
||||
self.passhasher = PasswordHasher()
|
||||
self.exiting = False
|
||||
|
||||
@staticmethod
|
||||
def auto_installer_fix(ex):
|
||||
logger.critical(f"Import Error: Unable to load {ex.name} module", exc_info=True)
|
||||
print(f"Import Error: Unable to load {ex.name} module")
|
||||
installer.do_install()
|
||||
|
||||
def float_to_string(self, gbs: int):
|
||||
s = str(float(gbs) * 1000).rstrip("0").rstrip(".")
|
||||
return s
|
||||
|
@ -6,7 +6,6 @@ import time
|
||||
import logging
|
||||
import tempfile
|
||||
from typing import Union
|
||||
from peewee import DoesNotExist
|
||||
|
||||
from app.classes.controllers.crafty_perms_controller import Crafty_Perms_Controller
|
||||
from app.classes.controllers.management_controller import Management_Controller
|
||||
@ -14,23 +13,25 @@ from app.classes.controllers.users_controller import Users_Controller
|
||||
from app.classes.controllers.roles_controller import Roles_Controller
|
||||
from app.classes.controllers.server_perms_controller import Server_Perms_Controller
|
||||
from app.classes.controllers.servers_controller import Servers_Controller
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
from app.classes.models.users import helper_users
|
||||
from app.classes.models.management import helpers_management
|
||||
from app.classes.models.servers import servers_helper
|
||||
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.server import Server
|
||||
from app.classes.shared.file_helpers import file_helper
|
||||
|
||||
from app.classes.minecraft.server_props import ServerProps
|
||||
from app.classes.minecraft.serverjars import server_jar_obj
|
||||
from app.classes.minecraft.stats import Stats
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
try:
|
||||
from peewee import DoesNotExist
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
helper.auto_installer_fix(err)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Controller:
|
||||
|
@ -1,30 +1,25 @@
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from app.classes.models.users import Users, users_helper
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
|
||||
from app.classes.models.users import Users, users_helper
|
||||
|
||||
# To disable warning about unused import ; Users is imported from here in other places
|
||||
#pylint: disable=self-assigning-variable
|
||||
# pylint: disable=self-assigning-variable
|
||||
Users = Users
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
try:
|
||||
# pylint: disable=unused-import
|
||||
from peewee import SqliteDatabase, fn
|
||||
from playhouse.shortcuts import model_to_dict
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
logger.critical(f"Import Error: Unable to load {err.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {err.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(err)
|
||||
|
||||
database = SqliteDatabase(helper.db_path, pragmas={
|
||||
logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
database = SqliteDatabase(helper.db_path, pragmas = {
|
||||
'journal_mode': 'wal',
|
||||
'cache_size': -1024 * 10})
|
||||
|
||||
|
@ -6,14 +6,11 @@ import sys
|
||||
import os
|
||||
import re
|
||||
from functools import wraps
|
||||
|
||||
from functools import cached_property
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import peewee
|
||||
from playhouse.migrate import (
|
||||
@ -23,10 +20,9 @@ try:
|
||||
)
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical("Import Error: Unable to load {} module".format(
|
||||
e.name), exc_info=True)
|
||||
console.critical("Import Error: Unable to load {} module".format(e.name))
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
MIGRATE_TABLE = 'migratehistory'
|
||||
MIGRATE_TEMPLATE = '''# Generated by database migrator
|
||||
@ -448,4 +444,4 @@ class MigrationManager(object):
|
||||
|
||||
migrator = self.migrator
|
||||
self.up_one(name, migrator, False, True)
|
||||
logger.warning('Rolled back migration: {}'.format(name))
|
||||
logger.warning('Rolled back migration: {}'.format(name))
|
||||
|
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import time
|
||||
import datetime
|
||||
@ -9,35 +8,29 @@ import logging.config
|
||||
import subprocess
|
||||
import html
|
||||
import tempfile
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
#TZLocal is set as a hidden import on win pipeline
|
||||
from tzlocal import get_localzone
|
||||
|
||||
from app.classes.minecraft.stats import Stats
|
||||
from app.classes.minecraft.mc_ping import ping, ping_bedrock
|
||||
from app.classes.models.servers import Server_Stats, servers_helper
|
||||
from app.classes.models.management import management_helper
|
||||
from app.classes.models.users import users_helper
|
||||
from app.classes.models.server_permissions import server_permissions
|
||||
|
||||
from app.classes.minecraft.stats import Stats
|
||||
from app.classes.minecraft.mc_ping import ping, ping_bedrock
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.shared.file_helpers import file_helper
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import psutil
|
||||
#TZLocal is set as a hidden import on win pipeline
|
||||
from tzlocal import get_localzone
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ServerOutBuf:
|
||||
lines = {}
|
||||
|
@ -1,35 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
import threading
|
||||
import asyncio
|
||||
import datetime
|
||||
from tzlocal import get_localzone
|
||||
|
||||
from app.classes.controllers.users_controller import Users_Controller
|
||||
from app.classes.minecraft.serverjars import server_jar_obj
|
||||
from app.classes.models.management import management_helper
|
||||
from app.classes.models.users import users_helper
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
|
||||
from app.classes.web.tornado_handler import Webserver
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
from app.classes.minecraft.serverjars import server_jar_obj
|
||||
from app.classes.models.management import management_helper
|
||||
from app.classes.controllers.users_controller import Users_Controller
|
||||
from app.classes.models.users import users_helper
|
||||
|
||||
logger = logging.getLogger('apscheduler')
|
||||
|
||||
try:
|
||||
from tzlocal import get_localzone
|
||||
from apscheduler.events import EVENT_JOB_EXECUTED
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
|
||||
except ModuleNotFoundError as err:
|
||||
logger.critical(f"Import Error: Unable to load {err.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {err.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(err)
|
||||
|
||||
logger = logging.getLogger('apscheduler')
|
||||
scheduler_intervals = { 'seconds',
|
||||
'minutes',
|
||||
'hours',
|
||||
|
@ -3,22 +3,25 @@ import html
|
||||
import re
|
||||
import logging
|
||||
import time
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
import bleach
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.shared.server import ServerOutBuf
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
|
||||
try:
|
||||
import bleach
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
|
||||
except ModuleNotFoundError as ex:
|
||||
helper.auto_installer_fix(ex)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AjaxHandler(BaseHandler):
|
||||
|
||||
def render_page(self, template, page_data):
|
||||
|
@ -3,8 +3,7 @@ import re
|
||||
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
bearer_pattern = re.compile(r'^Bearer', flags=re.IGNORECASE)
|
||||
|
||||
class ApiHandler(BaseHandler):
|
||||
@ -17,7 +16,7 @@ class ApiHandler(BaseHandler):
|
||||
def access_denied(self, user, reason=''):
|
||||
if reason:
|
||||
reason = ' because ' + reason
|
||||
log.info("User %s from IP %s was denied access to the API route " + self.request.path + reason, user, self.get_remote_ip())
|
||||
logger.info("User %s from IP %s was denied access to the API route " + self.request.path + reason, user, self.get_remote_ip())
|
||||
self.finish(self.return_response(403, {
|
||||
'error':'ACCESS_DENIED',
|
||||
'info':'You were denied access to the requested resource'
|
||||
@ -25,7 +24,7 @@ class ApiHandler(BaseHandler):
|
||||
|
||||
def authenticate_user(self) -> bool:
|
||||
try:
|
||||
log.debug("Searching for specified token")
|
||||
logger.debug("Searching for specified token")
|
||||
|
||||
api_token = self.get_argument('token', '')
|
||||
if api_token is None and self.request.headers.get('Authorization'):
|
||||
@ -34,10 +33,10 @@ class ApiHandler(BaseHandler):
|
||||
api_token = self.get_cookie('token')
|
||||
user_data = self.controller.users.get_user_by_api_token(api_token)
|
||||
|
||||
log.debug("Checking results")
|
||||
logger.debug("Checking results")
|
||||
if user_data:
|
||||
# Login successful! Check perms
|
||||
log.info(f"User {user_data['username']} has authenticated to API")
|
||||
logger.info(f"User {user_data['username']} has authenticated to API")
|
||||
# TODO: Role check
|
||||
|
||||
return True # This is to set the "authenticated"
|
||||
@ -46,7 +45,7 @@ class ApiHandler(BaseHandler):
|
||||
self.access_denied("unknown", "the user provided an invalid token")
|
||||
return False
|
||||
except Exception as e:
|
||||
log.warning("An error occured while authenticating an API user: %s", e)
|
||||
logger.warning("An error occured while authenticating an API user: %s", e)
|
||||
self.finish(self.return_response(403, {
|
||||
'error':'ACCESS_DENIED',
|
||||
'info':'An error occured while authenticating the user'
|
||||
|
@ -4,17 +4,21 @@ from typing import (
|
||||
List,
|
||||
Optional, Tuple, Dict, Any
|
||||
)
|
||||
import tornado.web
|
||||
import bleach
|
||||
|
||||
from app.classes.shared.authentication import authentication
|
||||
from app.classes.shared.main_controller import Controller
|
||||
|
||||
from app.classes.models.users import ApiKeys
|
||||
from app.classes.shared.authentication import authentication
|
||||
from app.classes.shared.main_controller import Controller
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
try:
|
||||
import tornado.web
|
||||
import bleach
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseHandler(tornado.web.RequestHandler):
|
||||
|
||||
nobleach = {bool, type(None)}
|
||||
|
@ -1,19 +1,22 @@
|
||||
import os
|
||||
import logging
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
import bleach
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.file_helpers import file_helper
|
||||
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
|
||||
try:
|
||||
import bleach
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FileHandler(BaseHandler):
|
||||
|
||||
def render_page(self, template, page_data):
|
||||
|
@ -1,9 +1,14 @@
|
||||
import logging
|
||||
import requests
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
try:
|
||||
import requests
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class HTTPHandler(BaseHandler):
|
||||
|
@ -5,27 +5,28 @@ from typing import Dict, Any, Tuple
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
import bleach
|
||||
import libgravatar
|
||||
import requests
|
||||
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
from tornado import iostream
|
||||
|
||||
#TZLocal is set as a hidden import on win pipeline
|
||||
from tzlocal import get_localzone
|
||||
from cron_validator import CronValidator
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
from app.classes.models.crafty_permissions import Enum_Permissions_Crafty
|
||||
from app.classes.models.management import management_helper
|
||||
|
||||
from app.classes.shared.authentication import authentication
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
try:
|
||||
import bleach
|
||||
import libgravatar
|
||||
import requests
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
from tornado import iostream
|
||||
#TZLocal is set as a hidden import on win pipeline
|
||||
from tzlocal import get_localzone
|
||||
from cron_validator import CronValidator
|
||||
|
||||
except ModuleNotFoundError as ex:
|
||||
helper.auto_installer_fix(ex)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class PanelHandler(BaseHandler):
|
||||
|
@ -1,23 +1,18 @@
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from app.classes.models.users import Users
|
||||
from app.classes.shared.authentication import authentication
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.main_models import fn
|
||||
|
||||
from app.classes.models.users import Users
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import bleach
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class PublicHandler(BaseHandler):
|
||||
|
||||
|
@ -1,30 +1,24 @@
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import libgravatar
|
||||
import requests
|
||||
|
||||
from app.classes.minecraft.serverjars import server_jar_obj
|
||||
from app.classes.models.crafty_permissions import Enum_Permissions_Crafty
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.file_helpers import file_helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.models.crafty_permissions import Enum_Permissions_Crafty
|
||||
from app.classes.minecraft.serverjars import server_jar_obj
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
import bleach
|
||||
import libgravatar
|
||||
import requests
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ServerHandler(BaseHandler):
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
from typing import ( Optional )
|
||||
import tornado.web
|
||||
|
||||
try:
|
||||
import tornado.web
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
from app.classes.shared.helpers import helper
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
class CustomStaticHandler(tornado.web.StaticFileHandler):
|
||||
def validate_absolute_path(self, root: str, absolute_path: str) -> Optional[str]:
|
||||
|
@ -4,7 +4,21 @@ import json
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.file_handler import FileHandler
|
||||
from app.classes.web.public_handler import PublicHandler
|
||||
from app.classes.web.panel_handler import PanelHandler
|
||||
from app.classes.web.default_handler import DefaultHandler
|
||||
from app.classes.web.server_handler import ServerHandler
|
||||
from app.classes.web.ajax_handler import AjaxHandler
|
||||
from app.classes.web.api_handler import ServersStats, NodeStats
|
||||
from app.classes.web.websocket_handler import SocketHandler
|
||||
from app.classes.web.static_handler import CustomStaticHandler
|
||||
from app.classes.web.upload_handler import UploadHandler
|
||||
from app.classes.web.http_handler import HTTPHandler, HTTPHandlerPage
|
||||
from app.classes.web.status_handler import StatusHandler
|
||||
|
||||
try:
|
||||
import tornado.web
|
||||
@ -14,26 +28,11 @@ try:
|
||||
import tornado.escape
|
||||
import tornado.locale
|
||||
import tornado.httpserver
|
||||
from app.classes.web.file_handler import FileHandler
|
||||
from app.classes.web.public_handler import PublicHandler
|
||||
from app.classes.web.panel_handler import PanelHandler
|
||||
from app.classes.web.default_handler import DefaultHandler
|
||||
from app.classes.web.server_handler import ServerHandler
|
||||
from app.classes.web.ajax_handler import AjaxHandler
|
||||
from app.classes.web.api_handler import ServersStats, NodeStats
|
||||
from app.classes.web.websocket_handler import SocketHandler
|
||||
from app.classes.web.static_handler import CustomStaticHandler
|
||||
from app.classes.web.upload_handler import UploadHandler
|
||||
from app.classes.web.http_handler import HTTPHandler, HTTPHandlerPage
|
||||
from app.classes.web.status_handler import StatusHandler
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.helpers import helper
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Webserver:
|
||||
|
||||
|
@ -2,23 +2,24 @@ import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import tornado.options
|
||||
import tornado.web
|
||||
import tornado.httpserver
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.main_controller import Controller
|
||||
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
|
||||
from app.classes.models.server_permissions import Enum_Permissions_Server
|
||||
try:
|
||||
import tornado.web
|
||||
import tornado.options
|
||||
import tornado.httpserver
|
||||
|
||||
except ModuleNotFoundError as ex:
|
||||
helper.auto_installer_fix(ex)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Class&Function Defination
|
||||
# Class & Function Defination
|
||||
MAX_STREAMED_SIZE = 1024 * 1024 * 1024
|
||||
|
||||
@tornado.web.stream_request_body
|
||||
|
@ -1,24 +1,19 @@
|
||||
import json
|
||||
import logging
|
||||
import asyncio
|
||||
import sys
|
||||
from urllib.parse import parse_qsl
|
||||
|
||||
from app.classes.shared.authentication import authentication
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.web.websocket_helper import websocket_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import tornado.websocket
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical(f"Import Error: Unable to load {e.name} module", exc_info=True)
|
||||
console.critical(f"Import Error: Unable to load {e.name} module")
|
||||
sys.exit(1)
|
||||
helper.auto_installer_fix(e)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class SocketHandler(tornado.websocket.WebSocketHandler):
|
||||
page = None
|
||||
|
Loading…
Reference in New Issue
Block a user