mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Make get_server_obj raise an error
Reason being: There is nothing that checks if it returns False
This commit is contained in:
parent
42af86b6f7
commit
821ed7ef5d
@ -5,7 +5,7 @@ import shutil
|
||||
import time
|
||||
import logging
|
||||
import tempfile
|
||||
from typing import Union
|
||||
from typing import Optional, Union
|
||||
from peewee import DoesNotExist
|
||||
|
||||
# TZLocal is set as a hidden import on win pipeline
|
||||
@ -276,13 +276,21 @@ class Controller:
|
||||
except:
|
||||
return {"percent": 0, "total_files": 0}
|
||||
|
||||
def get_server_obj(self, server_id: Union[str, int]) -> Union[bool, Server]:
|
||||
def get_server_obj(self, server_id: Union[str, int]) -> Server:
|
||||
for server in self.servers_list:
|
||||
if str(server["server_id"]) == str(server_id):
|
||||
return server["server_obj"]
|
||||
|
||||
logger.warning(f"Unable to find server object for server id {server_id}")
|
||||
return False # TODO: Change to None
|
||||
raise Exception(f"Unable to find server object for server id {server_id}")
|
||||
|
||||
def get_server_obj_optional(self, server_id: Union[str, int]) -> Optional[Server]:
|
||||
for server in self.servers_list:
|
||||
if str(server["server_id"]) == str(server_id):
|
||||
return server["server_obj"]
|
||||
|
||||
logger.warning(f"Unable to find server object for server id {server_id}")
|
||||
return None
|
||||
|
||||
def get_server_data(self, server_id: str):
|
||||
for server in self.servers_list:
|
||||
|
@ -84,10 +84,11 @@ class TasksManager:
|
||||
svr = self.controller.get_server_obj(cmd.server_id)
|
||||
except:
|
||||
logger.error(
|
||||
"Server value requested does note exist! "
|
||||
"Server value requested does not exist! "
|
||||
"Purging item from waiting commands."
|
||||
)
|
||||
HelpersManagement.mark_command_complete(cmd.command_id)
|
||||
continue
|
||||
|
||||
user_id = cmd.user_id
|
||||
command = cmd.command
|
||||
|
Loading…
Reference in New Issue
Block a user