From 5087813900c7de6cf210025ec158ddbd3c6161e6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jan 2022 14:43:22 -0500 Subject: [PATCH] add catch for restart command. Fix windows bug. --- app/classes/models/management.py | 2 +- app/classes/shared/server.py | 2 +- app/classes/shared/tasks.py | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/classes/models/management.py b/app/classes/models/management.py index 87d973eb..2d6f342f 100644 --- a/app/classes/models/management.py +++ b/app/classes/models/management.py @@ -156,7 +156,7 @@ class helpers_management: @staticmethod def get_unactioned_commands(): query = Commands.select().where(Commands.executed == 0) - return db_helper.return_rows(query) + return query @staticmethod def mark_command_complete(command_id=None): diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 843e28f7..9689b181 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -484,7 +484,7 @@ class Server: def remove_watcher_thread(self): logger.info("Removing old crash detection watcher thread") console.info("Removing old crash detection watcher thread") - schedule.clear(self.name) + self.crash_watcher_schedule.remove(self.server_name) def agree_eula(self, user_id): file = os.path.join(self.server_path, 'eula.txt') diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index 37200faf..8360f48f 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -85,9 +85,14 @@ class TasksManager: # select any commands waiting to be processed commands = management_helper.get_unactioned_commands() for c in commands: - svr = self.controller.get_server_obj(c['server_id']['server_id']) - user_id = c.get('user')['user_id'] - command = c.get('command', None) + try: + svr = self.controller.get_server_obj(c.server_id) + except: + logger.error("Server value requested does note exist purging item from waiting commands.") + management_helper.mark_command_complete(c.command_id) + + user_id = c.user_id + command = c.command if command == 'start_server': svr.run_threaded_server(user_id) @@ -105,7 +110,7 @@ class TasksManager: svr.jar_update() else: svr.send_command(command) - management_helper.mark_command_complete(c.get('command_id', None)) + management_helper.mark_command_complete(c.command_id) time.sleep(1)