From: Michael Tremer Date: Fri, 2 Dec 2016 00:37:48 +0000 (+0100) Subject: client: Add CLI to watch a build X-Git-Tag: 0.9.28~1285^2~1433 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10b3cc9c377f16237dc963573fe1420838d9aa88;p=pakfire.git client: Add CLI to watch a build This will follow a build and print live status on the console Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index d71384fac..743b631ac 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -25,6 +25,7 @@ import os import shutil import sys import tempfile +import time from . import base from . import client @@ -893,6 +894,11 @@ class CliClient(Cli): help=_("Check the connection to the hub")) check_connection.set_defaults(func=self.handle_check_connection) + # watch-build + watch_build = subparsers.add_parser("watch-build", help=_("Watch the status of a build")) + watch_build.add_argument("id", nargs=1, help=_("Build ID")) + watch_build.set_defaults(func=self.handle_watch_build) + return parser.parse_args() def handle_build(self, ns): @@ -944,6 +950,20 @@ class CliClient(Cli): if success: print("%s: %s" % (_("Connection OK"), success)) + def handle_watch_build(self, ns): + build = self.client.get_build(ns.id[0]) + + while True: + s = build.dump() + print(s) + + # Break the loop if the build is not active any more + # (since we don't expect any changes) + if not build.is_active(): + break + + time.sleep(60) + class CliDaemon(Cli): def __init__(self):