Agent should work
This commit is contained in:
@ -15,7 +15,7 @@ import requests
|
||||
from fastapi import BackgroundTasks
|
||||
|
||||
from ums.management.db import DB
|
||||
from ums.utils import AgentMessage, AgentResponse
|
||||
from ums.utils import AgentMessage, AgentResponse, logger
|
||||
|
||||
class MessageProcessor():
|
||||
|
||||
@ -41,11 +41,11 @@ class MessageProcessor():
|
||||
self.management_name = self._get_name(self.MANAGEMENT_URL)
|
||||
|
||||
if len(self.AGENTS_PROCESS) == 0:
|
||||
print("Not Process Agent (AGENTS_PROCESS) found, this may be a problem!")
|
||||
logger.warning(f"Not Process Agent (AGENTS_PROCESS) found, this may be a problem!")
|
||||
if len(self.AGENTS_SOLVE) == 0:
|
||||
print("Not Solve Agent (AGENTS_SOLVE) found, this may be a problem!")
|
||||
logger.warning(f"Not Solve Agent (AGENTS_SOLVE) found, this may be a problem!")
|
||||
if len(self.AGENTS_GATEKEEPER) == 0:
|
||||
print("Not Gatekeeper Agent (AGENTS_GATEKEEPER) found, this may be a problem!")
|
||||
logger.warning(f"Not Gatekeeper Agent (AGENTS_GATEKEEPER) found, this may be a problem!")
|
||||
|
||||
def _get_name(self, url:str) -> str:
|
||||
m = re.match(r'^https?://([^:]*)(?::(\d+))?$', url)
|
||||
@ -92,6 +92,11 @@ class MessageProcessor():
|
||||
self._send_messages(self.AGENTS_GATEKEEPER, db_message.message)
|
||||
|
||||
else: # all steps "done"
|
||||
|
||||
# validate not required? (then solved will never be set to true, thus set it here)
|
||||
if not db_message.message.status.validate.required:
|
||||
db_message.message.status.solved = True
|
||||
|
||||
if db_message.message.status.solved:
|
||||
# yay, message is solved
|
||||
self.db.set_solution(count=count, solution=True);
|
||||
@ -155,6 +160,6 @@ class MessageProcessor():
|
||||
self.db.set_processed(db_count, processed=True)
|
||||
return True
|
||||
else:
|
||||
print("Error sending message to:", recipient, (r.text, r.headers))
|
||||
logger.warning(f"Error sending message to: {recipient} {(r.text, r.headers)}")
|
||||
return False
|
||||
|
Reference in New Issue
Block a user