First working version
Only checks status for now.
This commit is contained in:
parent
2555c1b32f
commit
32876558ae
1 changed files with 19 additions and 14 deletions
|
@ -70,7 +70,7 @@ class OSCBot(Plugin):
|
|||
async def parse_status(
|
||||
self,
|
||||
project: str,
|
||||
package: Optional[str],
|
||||
package: Optional[str] = None,
|
||||
state: Optional[str] = None,
|
||||
repo: Optional[str] = None,
|
||||
arch: Optional[str] = None) -> List[BuildRepository]:
|
||||
|
@ -112,9 +112,9 @@ class OSCBot(Plugin):
|
|||
continue
|
||||
|
||||
packages = list()
|
||||
for state in child.status:
|
||||
package_name = state.get("package")
|
||||
package_status = state.get("code")
|
||||
for status in child.status:
|
||||
package_name = status.get("package")
|
||||
package_status = status.get("code")
|
||||
|
||||
if state and state != package_status:
|
||||
self.log.debug(f"Skipping {package_name},"
|
||||
|
@ -124,6 +124,9 @@ class OSCBot(Plugin):
|
|||
result = BuildResult(name=package_name, status=package_status)
|
||||
packages.append(result)
|
||||
|
||||
if not packages:
|
||||
continue
|
||||
|
||||
repository = BuildRepository(name=repository_name,
|
||||
arch=repo_arch,
|
||||
packages=packages)
|
||||
|
@ -150,21 +153,23 @@ class OSCBot(Plugin):
|
|||
repository: Optional[str] = None,
|
||||
arch: Optional[str] = None) -> None:
|
||||
|
||||
if state == "all":
|
||||
state = None
|
||||
if package == "all":
|
||||
package = None
|
||||
|
||||
response = await self.parse_status(project, package, state=state,
|
||||
repo=repository, arch=arch)
|
||||
|
||||
if not response:
|
||||
await evt.reply("No results returned.")
|
||||
await evt.reply("No results found.")
|
||||
return
|
||||
|
||||
header = self.template.from_string(HEADER_TEMPLATE)
|
||||
message = template.render(state=state, results=response)
|
||||
|
||||
self.log.error(sys.getsizeof(message))
|
||||
|
||||
try:
|
||||
await evt.reply(message, markdown=True)
|
||||
except Exception as exc:
|
||||
self.log.error(exc)
|
||||
await evt.reply("Error sending message")
|
||||
message = header.render(state=state)
|
||||
await evt.reply(message, markdown=True)
|
||||
for repository in response:
|
||||
body = self.template.from_string(REPO_TEMPLATE)
|
||||
message = body.render(repo=repository)
|
||||
await evt.respond(message, markdown=True)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue