diff options
author | Antoine Musso <hashar@free.fr> | 2014-08-18 23:45:43 +0200 |
---|---|---|
committer | Antoine Musso <hashar@free.fr> | 2014-08-18 23:51:09 +0200 |
commit | 9b22928f2b1cf02ec5f4144b126838d4ca62325e (patch) | |
tree | 2bced6ec9e7733f7388e9c7cf84cec2cefdf823d | |
parent | 2de0c2a37a8d52a09d1375e374deeec52fea38bf (diff) | |
download | zuul-9b22928f2b1cf02ec5f4144b126838d4ca62325e.tar.gz |
BuildSet now has a representation
I had Zuul Scheduler report warning messages such as:
zuul.Scheduler: Build set <zuul.model.BuildSet object at 0x1a9a310> is
not current
Which is not very meaningful. This adds a __repr__ to BuildSet which
shows up:
- the QueueItem representation
- number of builds in the set
- merge state
The merge states are internally stored using integer constants. I have
duplicated the information in a dict to lookup the int as a meaningful
string. That is not pretty :(
Change-Id: I0e087e4cb3f4c1da4ef40d0805793f737af1765e
-rw-r--r-- | zuul/model.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/zuul/model.py b/zuul/model.py index 77ab68bdf..1a99650a4 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -589,6 +589,12 @@ class BuildSet(object): PENDING = 2 COMPLETE = 3 + states_map = { + 1: 'NEW', + 2: 'PENDING', + 3: 'COMPLETE', + } + def __init__(self, item): self.item = item self.other_changes = [] @@ -603,6 +609,12 @@ class BuildSet(object): self.failing_reasons = [] self.merge_state = self.NEW + def __repr__(self): + return '<BuildSet item: %s #builds: %s merge state: %s>' % ( + self.item, + len(self.builds), + self.getStateName(self.merge_state)) + def setConfiguration(self): # The change isn't enqueued until after it's created # so we don't know what the other changes ahead will be @@ -615,6 +627,10 @@ class BuildSet(object): if not self.ref: self.ref = 'Z' + uuid4().hex + def getStateName(self, state_num): + return self.states_map.get( + state_num, 'UNKNOWN (%s)' % state_num) + def addBuild(self, build): self.builds[build.job.name] = build build.build_set = self |