diff --git a/osc/commandline.py b/osc/commandline.py index 53074d4c..d24d6dd8 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1178,21 +1178,31 @@ class Osc(cmdln.Cmdln): project = store_read_project(wd) apiurl = store_read_apiurl(wd) - offset = 0 - try: - while True: - log_chunk = get_log(apiurl, project, package, platform, arch, offset) - if len(log_chunk) == 0: - break - offset += len(log_chunk) - print log_chunk.strip() + print_buildlog(apiurl, project, package, platform, arch) - except urllib2.HTTPError, e: - print >>sys.stderr, 'Can\'t get logfile' - print >>sys.stderr, e - except KeyboardInterrupt: - pass + @cmdln.alias('rbl') + def do_remotebuildlog(self, subcmd, opts, *args): + """${cmd_name}: Shows the build log of a package + + Shows the log file of the build of a package. Can be used to follow the + log while it is being written. + + usage: + osc remotebuildlog project package platform arch + or + osc remotebuildlog project/package/platform/arch + ${cmd_option_list} + """ + args = slash_split(args) + if len(args) < 4: + print >>sys.stderr, "too few arguments" + sys.exit(1) + elif len(args) > 4: + print >>sys.stderr, "too many arguments" + sys.exit(1) + + print_buildlog(conf.config['apiurl'], *args) @cmdln.option('-x', '--extra-pkgs', metavar='PAC', action='append', diff --git a/osc/core.py b/osc/core.py index c4d5e268..1c502993 100755 --- a/osc/core.py +++ b/osc/core.py @@ -1805,11 +1805,25 @@ def get_prj_results(apiurl, prj, show_legend=False): return r -def get_log(apiurl, prj, package, platform, arch, offset): +def get_buildlog(apiurl, prj, package, platform, arch, offset): u = makeurl(apiurl, ['build', prj, platform, arch, package, '_log?nostream=1&start=%s' % offset]) f = http_GET(u) return f.read() +def print_buildlog(apiurl, prj, package, platform, arch, offset = 0): + """prints out the buildlog on stdout""" + try: + while True: + log_chunk = get_buildlog(apiurl, prj, package, platform, arch, offset) + if len(log_chunk) == 0: + break + offset += len(log_chunk) + print log_chunk.strip() + except urllib2.HTTPError, e: + print >>sys.stderr, 'Can\'t get logfile' + print >>sys.stderr, e + except KeyboardInterrupt: + pass def get_buildinfo(apiurl, prj, package, platform, arch, specfile=None, addlist=None): query = []