1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-23 13:31:48 +01:00

- do_buildlog: support "osc bl repo"

In this case, "osc bl repo" behaves more or less the same as "osc rbl repo"
(in case no corresponding .osc/_buildinfo file exists, we default to
repo and hostarch).
This commit is contained in:
Marcus Huewe 2016-02-05 16:10:43 +01:00
parent 8a78be684e
commit 5d068b091a

View File

@ -5074,21 +5074,29 @@ Please submit there instead, or use --nodevelproject to force direct submission.
${cmd_usage} [REPOSITORY ARCH | BUILDLOGURL] ${cmd_usage} [REPOSITORY ARCH | BUILDLOGURL]
${cmd_option_list} ${cmd_option_list}
""" """
import osc.build
repository = arch = None project = package = repository = arch = None
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 1 and args[0].startswith('http'): if len(args) == 1 and args[0].startswith('http'):
apiurl, project, package, repository, arch = parse_buildlogurl(args[0]) apiurl, project, package, repository, arch = parse_buildlogurl(args[0])
else:
project = store_read_project(os.curdir)
package = store_read_package(os.curdir)
if len(args) == 1:
repository, arch = self._find_last_repo_arch(args[0], fatal=False)
if repository is None:
# no local build with this repo was done
print('failed to guess arch, using hostarch')
repository = args[0]
arch = osc.build.hostarch
elif len(args) < 2: elif len(args) < 2:
self.print_repos() self.print_repos()
elif len(args) > 2: elif len(args) > 2:
raise oscerr.WrongArgs('Too many arguments.') raise oscerr.WrongArgs('Too many arguments.')
else: else:
wd = os.curdir
package = store_read_package(wd)
project = store_read_project(wd)
repository = args[0] repository = args[0]
arch = args[1] arch = args[1]
@ -5191,6 +5199,26 @@ Please submit there instead, or use --nodevelproject to force direct submission.
strip_time = opts.strip_time or conf.config['buildlog_strip_time'] strip_time = opts.strip_time or conf.config['buildlog_strip_time']
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last) print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last)
def _find_last_repo_arch(self, repo=None, fatal=True):
import glob
files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*"))
if repo is not None:
files = [f for f in files
if os.path.basename(f).replace('_buildinfo-', '').startswith(repo + '-')]
if not files:
if not fatal:
return None, None
self.print_repos()
cfg = files[0]
# find newest file
for f in files[1:]:
if os.stat(f).st_mtime > os.stat(cfg).st_mtime:
cfg = f
root = ET.parse(cfg).getroot()
repo = root.get("repository")
arch = root.find("arch").text
return repo, arch
@cmdln.alias('lbl') @cmdln.alias('lbl')
@cmdln.option('-o', '--offset', metavar='OFFSET', @cmdln.option('-o', '--offset', metavar='OFFSET',
help='get log starting from offset') help='get log starting from offset')
@ -5211,23 +5239,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
sys.exit(1) sys.exit(1)
if len(args) == 0 or len(args) == 1: if len(args) == 0 or len(args) == 1:
project = store_read_project('.')
package = store_read_package('.') package = store_read_package('.')
import glob repo = None
files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*"))
if args: if args:
files = [f for f in files repo = args[0]
if os.path.basename(f).replace('_buildinfo-', '').startswith(args[0] + '-')] repo, arch = self._find_last_repo_arch(repo)
if not files:
self.print_repos()
cfg = files[0]
# find newest file
for f in files[1:]:
if os.stat(f).st_mtime > os.stat(cfg).st_mtime:
cfg = f
root = ET.parse(cfg).getroot()
project = root.get("project")
repo = root.get("repository")
arch = root.find("arch").text
elif len(args) == 2: elif len(args) == 2:
project = store_read_project('.') project = store_read_project('.')
package = store_read_package('.') package = store_read_package('.')