Add a new subcommand to trigger services
This commit is contained in:
parent
aca97152c7
commit
e1a5879e41
1 changed files with 28 additions and 4 deletions
|
@ -205,13 +205,37 @@ class OSCBot(Plugin):
|
|||
|
||||
await evt.reply(message, markdown=True)
|
||||
|
||||
@osc.subcommand(
|
||||
"servicerun",
|
||||
help="Trigger source services for a package")
|
||||
@command.argument("project", "project name")
|
||||
@command.argument("package", "package name")
|
||||
async def servicerun(self, evt: MessageEvent,
|
||||
project: str,
|
||||
package: str) -> None:
|
||||
|
||||
token = self.config["trigger_token"]
|
||||
trigger_url = f"{self.config['api_url']}/trigger/runservice"
|
||||
params = {"project": project, "package": package}
|
||||
header = {"Authorization": f"Token {token}"}
|
||||
|
||||
response = await self.http.post(trigger_url, params=params,
|
||||
headers=header)
|
||||
|
||||
status = objectify.fromstring(await response.text())
|
||||
if response.status == 200:
|
||||
message = f"Service triggered: {status.summary.text}"
|
||||
else:
|
||||
message = f"Error running service: {status.summary.text}"
|
||||
await evt.reply(message, markdown=True)
|
||||
|
||||
@osc.subcommand("status", aliases=("st",),
|
||||
help="Check status for package and repository")
|
||||
@command.argument("project", "project name")
|
||||
@command.argument("package", "package name (optional)", required=False)
|
||||
@command.argument("state", "build state (optional)", required=False)
|
||||
@command.argument("repository", "repository (optional)", required=False)
|
||||
@command.argument("arch", "architecture state (optional)", required=False)
|
||||
@command.argument("package", "package name | all", required=False)
|
||||
@command.argument("state", "build state | all", required=False)
|
||||
@command.argument("repository", "repository | all)", required=False)
|
||||
@command.argument("arch", "architecture state | all", required=False)
|
||||
async def status(self, evt: MessageEvent,
|
||||
project: str,
|
||||
package: Optional[str] = None,
|
||||
|
|
Loading…
Add table
Reference in a new issue