From e101e36202c521db74490098772efe79828707c1 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Oct 03 2023 13:23:01 +0000 Subject: ... --- diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py index 080703b..98ce58a 100644 --- a/kojihub/kojihub.py +++ b/kojihub/kojihub.py @@ -93,6 +93,7 @@ from .db import ( # noqa: F401 nextval, currval, ) +from .task import Task from .util import convert_value diff --git a/kojihub/task.py b/kojihub/task.py index e515b38..db0dd39 100644 --- a/kojihub/task.py +++ b/kojihub/task.py @@ -1,4 +1,17 @@ # Task related hub code +import base64 +import logging +import time +import xmlrpc.client + +import koji +from .db import QueryProcessor, UpdateProcessor +from .util import convert_value +from koji.context import context +from koji.util import decode_bytes + + +logger = logging.getLogger('koji.hub.task') class Task(object): @@ -106,12 +119,13 @@ class Task(object): otherhost = r['host_id'] if state == koji.TASK_STATES['FREE']: if otherhost is not None: - log_error(f"Error: task {task_id} is both free " - f"and handled by host {otherhost}") + logger.error(f"Error: task {task_id} is both free " + f"and handled by host {otherhost}") return False elif state == koji.TASK_STATES['ASSIGNED']: if otherhost is None: - log_error(f"Error: task {task_id} is assigned, but no host is really assigned") + logger.error(f"Error: task {task_id} is assigned, but no host is really " + "assigned") return False elif otherhost != host_id: # task is assigned to someone else, no error just return @@ -119,7 +133,7 @@ class Task(object): elif newstate == 'ASSIGNED': # double assign is a weird situation but we can return True as state doesn't # really change - log_error(f"Error: double assign of task {task_id} and host {host_id}") + logger.error(f"Error: double assign of task {task_id} and host {host_id}") return True # otherwise the task is assigned to host_id, so keep going elif state == koji.TASK_STATES['CANCELED']: @@ -127,16 +141,16 @@ class Task(object): return False elif state == koji.TASK_STATES['OPEN']: if otherhost is None: - log_error(f"Error: task {task_id} is opened but not handled by any host") + logger.error(f"Error: task {task_id} is opened but not handled by any host") elif otherhost == host_id: - log_error(f"Error: task {task_id} is already open and handled by " - f"{host_id} (double open/assign)") + logger.error(f"Error: task {task_id} is already open and handled by " + f"{host_id} (double open/assign)") return False else: # state is CLOSED or FAILED if otherhost is None: - log_error(f"Error: task {task_id} is non-free but not handled by any host " - f"(state {koji.TASK_STATES[state]})") + logger.error(f"Error: task {task_id} is non-free but not handled by any host " + f"(state {koji.TASK_STATES[state]})") return False # if we reach here, task is either # - free and unlocked