|
| 1 | +from rpmUtils.miscutils import splitFilename |
| 2 | +from boss.obs import BuildServiceParticipant, RepositoryMixin |
| 3 | + |
| 4 | + |
| 5 | +class ParticipantHandler(BuildServiceParticipant, RepositoryMixin): |
| 6 | + """Participant class as defined in SkyNET API.""" |
| 7 | + |
| 8 | + def __init__(self): |
| 9 | + """Initializator.""" |
| 10 | + |
| 11 | + BuildServiceParticipant.__init__(self) |
| 12 | + |
| 13 | + def handle_wi_control(self, ctrl): |
| 14 | + """Control job thread.""" |
| 15 | + pass |
| 16 | + |
| 17 | + @BuildServiceParticipant.get_oscrc |
| 18 | + def handle_lifecycle_control(self, ctrl): |
| 19 | + """Control participant thread.""" |
| 20 | + pass |
| 21 | + |
| 22 | + @BuildServiceParticipant.setup_obs |
| 23 | + def handle_wi(self, wid): |
| 24 | + """Handle workitem.""" |
| 25 | + if not wid.fields.versions: |
| 26 | + return |
| 27 | + versions = wid.fields.versions.as_dict() |
| 28 | + for pkg, d in versions.items(): |
| 29 | + target = "%s/%s" % (d["repository"], d["arch"]) |
| 30 | + |
| 31 | + for binary in self.obs.getBinaryList(d["project"], target, pkg): |
| 32 | + n, v, r, e, a = splitFilename(binary) |
| 33 | + if n != d.get("binary", pkg): |
| 34 | + continue |
| 35 | + bininfo = self.obs.getBinaryInfo(d["project"], |
| 36 | + target, pkg, binary) |
| 37 | + versions[pkg].update({"version": v, |
| 38 | + "release": r.split("."), |
| 39 | + "epoch": e, |
| 40 | + "arch": a, |
| 41 | + "summary": bininfo["summary"], |
| 42 | + "description": bininfo["description"]}) |
| 43 | + |
| 44 | + wid.fields.versions = versions |
0 commit comments