From 2a3179130ba9bd009194d94c57796781954c3df5 Mon Sep 17 00:00:00 2001
From: Alok Ranjan <alok.ranjan@linaro.org>
Date: Thu, 28 Nov 2024 20:12:21 +0100
Subject: [PATCH 2/2] jobs: Enhance support for job priority values

This commit improves the handling of LAVA job priority values by
allowing the use of descriptive levels (low, medium, high) in addition
to the existing numerical range (1-100).

Signed-off-by: Alok Ranjan <alok.ranjan@linaro.org>
---
 tuxlava/jobs.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tuxlava/jobs.py b/tuxlava/jobs.py
index c5a0313340c1..2c617a171f51 100644
--- a/tuxlava/jobs.py
+++ b/tuxlava/jobs.py
@@ -7,6 +7,7 @@
 #
 # SPDX-License-Identifier: MIT
 
+import re
 import shlex
 import tempfile
 
@@ -136,9 +137,9 @@ class Job:
         priority = (
             self.parameters.get("LAVA_JOB_PRIORITY", 50) if self.parameters else 50
         )
-        if int(priority) > 100 or int(priority) <= 0:
+        if not re.match("^(100|[1-9][0-9]?|low|medium|high)$", str(priority)):
             raise InvalidArgument(
-                "argument --parameters LAVA_JOB_PRIORITY must be a value between 1-100"
+                "argument --parameters LAVA_JOB_PRIORITY must be a value between 1-100 or one of 'low', 'medium' or 'high'"
             )
         return priority
 
-- 
2.45.2

