def from_build_id( cls, topic: str, build_id: int, chroot: str, status: int, owner: str, project_name: str, pkg: str, timestamp, ) -> Optional["AbstractCoprBuildEvent"]: """Return cls instance or None if build_id not in CoprBuildDB""" build: Optional[Union[SRPMBuildModel, CoprBuildModel]] if chroot == COPR_SRPM_CHROOT: build = SRPMBuildModel.get_by_copr_build_id(str(build_id)) else: build = CoprBuildModel.get_by_build_id(str(build_id), chroot) if not build: logger.warning( f"Build id {build_id} not in " f"{'SRPMBuildDB' if chroot == COPR_SRPM_CHROOT else 'CoprBuildDB'}." ) return None return cls(topic, build_id, build, chroot, status, owner, project_name, pkg, timestamp)
def build(self): if not self._build: build_id = str(self.copr_event.build_id) if self.copr_event.chroot == COPR_SRPM_CHROOT: self._build = SRPMBuildModel.get_by_copr_build_id(build_id) else: self._build = CoprBuildModel.get_by_build_id( build_id, self.copr_event.chroot) return self._build