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(
|
async def parse_status(
|
||||||
self,
|
self,
|
||||||
project: str,
|
project: str,
|
||||||
package: Optional[str],
|
package: Optional[str] = None,
|
||||||
state: Optional[str] = None,
|
state: Optional[str] = None,
|
||||||
repo: Optional[str] = None,
|
repo: Optional[str] = None,
|
||||||
arch: Optional[str] = None) -> List[BuildRepository]:
|
arch: Optional[str] = None) -> List[BuildRepository]:
|
||||||
|
@ -112,9 +112,9 @@ class OSCBot(Plugin):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
packages = list()
|
packages = list()
|
||||||
for state in child.status:
|
for status in child.status:
|
||||||
package_name = state.get("package")
|
package_name = status.get("package")
|
||||||
package_status = state.get("code")
|
package_status = status.get("code")
|
||||||
|
|
||||||
if state and state != package_status:
|
if state and state != package_status:
|
||||||
self.log.debug(f"Skipping {package_name},"
|
self.log.debug(f"Skipping {package_name},"
|
||||||
|
@ -124,6 +124,9 @@ class OSCBot(Plugin):
|
||||||
result = BuildResult(name=package_name, status=package_status)
|
result = BuildResult(name=package_name, status=package_status)
|
||||||
packages.append(result)
|
packages.append(result)
|
||||||
|
|
||||||
|
if not packages:
|
||||||
|
continue
|
||||||
|
|
||||||
repository = BuildRepository(name=repository_name,
|
repository = BuildRepository(name=repository_name,
|
||||||
arch=repo_arch,
|
arch=repo_arch,
|
||||||
packages=packages)
|
packages=packages)
|
||||||
|
@ -150,21 +153,23 @@ class OSCBot(Plugin):
|
||||||
repository: Optional[str] = None,
|
repository: Optional[str] = None,
|
||||||
arch: Optional[str] = None) -> 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,
|
response = await self.parse_status(project, package, state=state,
|
||||||
repo=repository, arch=arch)
|
repo=repository, arch=arch)
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
await evt.reply("No results returned.")
|
await evt.reply("No results found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
header = self.template.from_string(HEADER_TEMPLATE)
|
header = self.template.from_string(HEADER_TEMPLATE)
|
||||||
message = template.render(state=state, results=response)
|
message = header.render(state=state)
|
||||||
|
await evt.reply(message, markdown=True)
|
||||||
self.log.error(sys.getsizeof(message))
|
for repository in response:
|
||||||
|
body = self.template.from_string(REPO_TEMPLATE)
|
||||||
try:
|
message = body.render(repo=repository)
|
||||||
await evt.reply(message, markdown=True)
|
await evt.respond(message, markdown=True)
|
||||||
except Exception as exc:
|
|
||||||
self.log.error(exc)
|
|
||||||
await evt.reply("Error sending message")
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue