From 7bf67bc21f497644e17faec9ac31aeccd56cbd19 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 1 Oct 2019 17:36:49 +0800 Subject: [PATCH] introduce priority system --- buildbot.py | 3 +++ yamlparse.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/buildbot.py b/buildbot.py index ce2c008..861daea 100755 --- a/buildbot.py +++ b/buildbot.py @@ -67,6 +67,8 @@ class Job: ret += f'{myproperty}={getattr(self, myproperty, None)},' ret += ')' return ret + def __lt__(self, job2): + return self.pkgconfig.priority < job2.pkgconfig.priority class jobsManager: def __init__(self): self.__buildjobs = list() @@ -186,6 +188,7 @@ class jobsManager: return self.__get_job() jobs = self.__buildjobs if jobs: + jobs.sort(reverse=True) self.__curr_job = jobs.pop(0) return self.__curr_job def __finish_job(self, pkgdir, force=False): diff --git a/yamlparse.py b/yamlparse.py index 584029f..30c51b1 100644 --- a/yamlparse.py +++ b/yamlparse.py @@ -20,7 +20,7 @@ os.chdir(abspath) REPO_ROOT = Path(PKGBUILD_DIR) class pkgConfig: - def __init__(self, dirname, pkgtype, cleanbuild, timeout, extra): + def __init__(self, dirname, pkgtype, cleanbuild, timeout, priority, extra): self.dirname = dirname self.type = pkgtype @@ -33,6 +33,7 @@ class pkgConfig: self.timeout = 30 if timeout is None else int(timeout) # timeout in minutes + self.priority = 0 if priority is None else int(priority) self.__extra = extra self.__process_extra() @@ -62,7 +63,7 @@ class pkgConfig: ret = "pkgConfig(" for myproperty in \ ( - 'dirname', 'type', 'cleanbuild', 'timeout', + 'dirname', 'type', 'cleanbuild', 'timeout', 'priority', 'prebuild', 'postbuild', 'update', 'failure' ): ret += f'{myproperty}={getattr(self, myproperty, None)},' @@ -82,7 +83,7 @@ def load_all(): content = load(content, Loader=Loader) assert type(content) is dict args = [content.get(part, None) for part in \ - ('type', 'cleanbuild', 'timeout', 'extra')] + ('type', 'cleanbuild', 'timeout', 'priority', 'extra')] args = [mydir.name] + args pkgconfigs.append(pkgConfig(*args)) else: