mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Appease black
This commit is contained in:
parent
de17278255
commit
34f1acd3e2
@ -167,7 +167,6 @@ class ServersController(metaclass=Singleton):
|
||||
raise Exception(f"Unable to find server object for server id {server_id}")
|
||||
|
||||
def init_all_servers(self):
|
||||
|
||||
servers = self.get_all_defined_servers()
|
||||
self.failed_servers = []
|
||||
|
||||
@ -228,7 +227,6 @@ class ServersController(metaclass=Singleton):
|
||||
)
|
||||
|
||||
def check_server_loaded(self, server_id_to_check: int):
|
||||
|
||||
logger.info(f"Checking to see if we already registered {server_id_to_check}")
|
||||
|
||||
for server in self.servers_list:
|
||||
|
@ -19,7 +19,6 @@ class Server:
|
||||
self.description = data.get("description")
|
||||
# print(self.description)
|
||||
if isinstance(self.description, dict):
|
||||
|
||||
# cat server
|
||||
if "translate" in self.description:
|
||||
self.description = self.description["translate"]
|
||||
|
@ -104,7 +104,6 @@ class ServerJars:
|
||||
logger.error(f"Unable to update serverjars.com cache file: {e}")
|
||||
|
||||
def refresh_cache(self):
|
||||
|
||||
cache_file = self.helper.serverjar_cache
|
||||
cache_old = self.helper.is_file_older_than_x_days(cache_file)
|
||||
|
||||
|
@ -211,7 +211,6 @@ class Stats:
|
||||
|
||||
@staticmethod
|
||||
def get_world_size(server_path):
|
||||
|
||||
total_size = 0
|
||||
|
||||
total_size = Helpers.get_dir_size(server_path)
|
||||
@ -221,7 +220,6 @@ class Stats:
|
||||
return level_total_size
|
||||
|
||||
def get_server_players(self, server_id):
|
||||
|
||||
server = HelperServers.get_server_data_by_id(server_id)
|
||||
|
||||
logger.info(f"Getting players for server {server}")
|
||||
@ -295,7 +293,6 @@ class Stats:
|
||||
|
||||
@staticmethod
|
||||
def parse_server_raknet_ping(ping_obj: object):
|
||||
|
||||
try:
|
||||
server_icon = base64.encodebytes(ping_obj["icon"])
|
||||
except Exception as e:
|
||||
|
@ -15,6 +15,7 @@ from app.classes.shared.permission_helper import PermissionHelper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# User_Crafty Class
|
||||
# **********************************************************************************
|
||||
|
@ -20,6 +20,7 @@ from app.classes.shared.main_models import DatabaseShortcuts
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Audit_Log Class
|
||||
# **********************************************************************************
|
||||
|
@ -15,6 +15,7 @@ from app.classes.shared.helpers import Helpers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Roles Class
|
||||
# **********************************************************************************
|
||||
|
@ -16,6 +16,7 @@ from app.classes.shared.permission_helper import PermissionHelper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Role Servers Class
|
||||
# **********************************************************************************
|
||||
|
@ -29,6 +29,7 @@ logger = logging.getLogger(__name__)
|
||||
peewee_logger = logging.getLogger("peewee")
|
||||
peewee_logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Servers Stats Class
|
||||
# **********************************************************************************
|
||||
|
@ -15,6 +15,7 @@ from app.classes.models.base_model import BaseModel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Servers Model
|
||||
# **********************************************************************************
|
||||
|
@ -21,6 +21,7 @@ from app.classes.models.roles import Roles, HelperRoles
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# Users Class
|
||||
# **********************************************************************************
|
||||
@ -58,6 +59,7 @@ PUBLIC_USER_ATTRS: t.Final = [
|
||||
"lang", # maybe remove?
|
||||
]
|
||||
|
||||
|
||||
# **********************************************************************************
|
||||
# API Keys Class
|
||||
# **********************************************************************************
|
||||
|
@ -58,7 +58,6 @@ class MainPrompt(cmd.Cmd):
|
||||
Console.info("Unknown migration command")
|
||||
|
||||
def do_set_passwd(self, line):
|
||||
|
||||
try:
|
||||
username = str(line).lower()
|
||||
# If no user is found it returns None
|
||||
|
@ -604,7 +604,6 @@ class Helpers:
|
||||
|
||||
# open our file
|
||||
with open(file_name, "r", encoding="utf-8") as f:
|
||||
|
||||
# seek
|
||||
f.seek(0, 2)
|
||||
|
||||
@ -769,7 +768,6 @@ class Helpers:
|
||||
|
||||
@staticmethod
|
||||
def get_file_contents(path: str, lines=100):
|
||||
|
||||
contents = ""
|
||||
|
||||
if os.path.exists(path) and os.path.isfile(path):
|
||||
@ -790,12 +788,10 @@ class Helpers:
|
||||
return False
|
||||
|
||||
def create_session_file(self, ignore=False):
|
||||
|
||||
if ignore and os.path.exists(self.session_file):
|
||||
os.remove(self.session_file)
|
||||
|
||||
if os.path.exists(self.session_file):
|
||||
|
||||
file_data = self.get_file_contents(self.session_file)
|
||||
try:
|
||||
data = json.loads(file_data)
|
||||
@ -905,7 +901,6 @@ class Helpers:
|
||||
return False
|
||||
|
||||
def create_self_signed_cert(self, cert_dir=None):
|
||||
|
||||
if cert_dir is None:
|
||||
cert_dir = os.path.join(self.config_dir, "web", "certs")
|
||||
|
||||
@ -1066,7 +1061,6 @@ class Helpers:
|
||||
return output
|
||||
|
||||
def generate_dir(self, folder, output=""):
|
||||
|
||||
dir_list = []
|
||||
unsorted_files = []
|
||||
file_list = os.listdir(folder)
|
||||
|
@ -226,7 +226,6 @@ class ImportHelpers:
|
||||
download_thread.start()
|
||||
|
||||
def download_threaded_bedrock_server(self, path, new_id):
|
||||
|
||||
# downloads zip from remote url
|
||||
try:
|
||||
bedrock_url = Helpers.get_latest_bedrock_url()
|
||||
|
@ -10,7 +10,6 @@ class Install:
|
||||
)
|
||||
|
||||
def do_install(self):
|
||||
|
||||
# are we in a venv?
|
||||
if not self.is_venv():
|
||||
print("Crafty Requires a venv to install")
|
||||
|
@ -942,7 +942,6 @@ class Controller:
|
||||
def remove_server(self, server_id, files):
|
||||
counter = 0
|
||||
for server in self.servers.servers_list:
|
||||
|
||||
# if this is the droid... im mean server we are looking for...
|
||||
if str(server["server_id"]) == str(server_id):
|
||||
server_data = self.servers.get_server_data(server_id)
|
||||
|
@ -592,7 +592,6 @@ class ServerInstance:
|
||||
# We need to grab the exact forge version number.
|
||||
# We know we can find it here in the run.sh/bat script.
|
||||
try:
|
||||
|
||||
# Getting the forge version from the executable command
|
||||
version = re.findall(
|
||||
r"forge-([0-9\.]+)((?:)|(?:-([0-9\.]+)-[a-zA-Z]+)).jar",
|
||||
@ -852,7 +851,6 @@ class ServerInstance:
|
||||
return True
|
||||
|
||||
def crash_detected(self, name):
|
||||
|
||||
# clear the old scheduled watcher task
|
||||
self.server_scheduler.remove_job(f"c_{self.server_id}")
|
||||
# remove the stats polling job since server is stopped
|
||||
@ -914,7 +912,6 @@ class ServerInstance:
|
||||
return self.process.pid if self.process is not None else None
|
||||
|
||||
def detect_crash(self):
|
||||
|
||||
logger.info(f"Detecting possible crash for server: {self.name} ")
|
||||
|
||||
running = self.check_running()
|
||||
@ -937,7 +934,6 @@ class ServerInstance:
|
||||
self.stats_helper.sever_crashed()
|
||||
# if we haven't tried to restart more 3 or more times
|
||||
if self.restart_count <= 3:
|
||||
|
||||
# start the server if needed
|
||||
server_restarted = self.crash_detected(self.name)
|
||||
|
||||
@ -1463,7 +1459,6 @@ class ServerInstance:
|
||||
Console.critical("Can't broadcast server status to websocket")
|
||||
|
||||
def get_servers_stats(self):
|
||||
|
||||
server_stats = {}
|
||||
|
||||
logger.info("Getting Stats for Server " + self.name + " ...")
|
||||
@ -1550,7 +1545,6 @@ class ServerInstance:
|
||||
return server_stats
|
||||
|
||||
def get_server_players(self):
|
||||
|
||||
server = HelperServers.get_server_data_by_id(self.server_id)
|
||||
|
||||
logger.info(f"Getting players for server {server}")
|
||||
@ -1571,7 +1565,6 @@ class ServerInstance:
|
||||
return []
|
||||
|
||||
def get_raw_server_stats(self, server_id):
|
||||
|
||||
try:
|
||||
server = HelperServers.get_server_obj(server_id)
|
||||
except:
|
||||
@ -1720,7 +1713,6 @@ class ServerInstance:
|
||||
return server_stats
|
||||
|
||||
def record_server_stats(self):
|
||||
|
||||
server_stats = self.get_servers_stats()
|
||||
self.stats_helper.insert_server_stats(server_stats)
|
||||
|
||||
|
@ -672,7 +672,6 @@ class TasksManager:
|
||||
host_stats = HelpersManagement.get_latest_hosts_stats()
|
||||
|
||||
while True:
|
||||
|
||||
if host_stats.get(
|
||||
"cpu_usage"
|
||||
) != HelpersManagement.get_latest_hosts_stats().get(
|
||||
|
@ -6,7 +6,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DefaultHandler(BaseHandler):
|
||||
|
||||
# Override prepare() instead of get() to cover all possible HTTP methods.
|
||||
def prepare(self, page=None): # pylint: disable=arguments-differ
|
||||
if page is not None:
|
||||
|
@ -10,7 +10,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class PublicHandler(BaseHandler):
|
||||
def set_current_user(self, user_id: str = None):
|
||||
|
||||
expire_days = self.helper.get_setting("cookie_expire")
|
||||
|
||||
# if helper comes back with false
|
||||
@ -29,7 +28,6 @@ class PublicHandler(BaseHandler):
|
||||
# self.clear_cookie("user_data")
|
||||
|
||||
def get(self, page=None):
|
||||
|
||||
error = bleach.clean(self.get_argument("error", "Invalid Login!"))
|
||||
error_msg = bleach.clean(self.get_argument("error_msg", ""))
|
||||
|
||||
@ -81,7 +79,6 @@ class PublicHandler(BaseHandler):
|
||||
)
|
||||
|
||||
def post(self, page=None):
|
||||
|
||||
error = bleach.clean(self.get_argument("error", "Invalid Login!"))
|
||||
error_msg = bleach.clean(self.get_argument("error_msg", ""))
|
||||
|
||||
@ -96,7 +93,6 @@ class PublicHandler(BaseHandler):
|
||||
page_data["query"] = self.request.query
|
||||
|
||||
if page == "login":
|
||||
|
||||
next_page = "/login"
|
||||
if self.request.query:
|
||||
next_page = "/login?" + self.request.query
|
||||
|
@ -26,7 +26,6 @@ login_schema = {
|
||||
|
||||
class ApiAuthLoginHandler(BaseApiHandler):
|
||||
def post(self):
|
||||
|
||||
try:
|
||||
data = json.loads(self.request.body)
|
||||
except json.decoder.JSONDecodeError as e:
|
||||
|
@ -631,7 +631,6 @@ class ApiServersIndexHandler(BaseApiHandler):
|
||||
self.finish_json(200, {"status": "ok", "data": auth_data[0]})
|
||||
|
||||
def post(self):
|
||||
|
||||
auth_data = self.authenticate_user()
|
||||
if not auth_data:
|
||||
return
|
||||
|
@ -552,7 +552,6 @@ class ServerHandler(BaseHandler):
|
||||
self.get_remote_ip(),
|
||||
)
|
||||
else:
|
||||
|
||||
new_server_id = self.controller.create_bedrock_server(
|
||||
server_name,
|
||||
exec_user["user_id"],
|
||||
|
@ -59,7 +59,6 @@ class Webserver:
|
||||
|
||||
@staticmethod
|
||||
def log_function(handler):
|
||||
|
||||
info = {
|
||||
"Status_Code": handler.get_status(),
|
||||
"Method": handler.request.method,
|
||||
@ -103,7 +102,6 @@ class Webserver:
|
||||
logger.debug("Applied asyncio patch")
|
||||
|
||||
def run_tornado(self):
|
||||
|
||||
# let's verify we have an SSL cert
|
||||
self.helper.create_self_signed_cert()
|
||||
|
||||
|
@ -18,7 +18,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@tornado.web.stream_request_body
|
||||
class UploadHandler(BaseHandler):
|
||||
|
||||
# noinspection PyAttributeOutsideInit
|
||||
def initialize(
|
||||
self,
|
||||
@ -173,7 +172,6 @@ class UploadHandler(BaseHandler):
|
||||
if not self.request.headers.get("X-Content-Type", None).startswith(
|
||||
"image/"
|
||||
):
|
||||
|
||||
return self.finish_json(
|
||||
415,
|
||||
{
|
||||
|
@ -79,7 +79,6 @@ class SocketHandler(tornado.websocket.WebSocketHandler):
|
||||
# pylint: disable=arguments-renamed
|
||||
@staticmethod
|
||||
def on_message(raw_message):
|
||||
|
||||
logger.debug(f"Got message from WebSocket connection {raw_message}")
|
||||
message = json.loads(raw_message)
|
||||
logger.debug(f"Event Type: {message['event']}, Data: {message['data']}")
|
||||
|
Loading…
Reference in New Issue
Block a user