Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Thaodan:tools
osc
0009-Add-buildlog-option-to-fetch-buildlog-not-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0009-Add-buildlog-option-to-fetch-buildlog-not-relative-t.patch of Package osc
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <bjorn.bidar@jolla.com> Date: Tue, 2 Jan 2024 12:28:20 +0200 Subject: [PATCH] Add buildlog option to fetch buildlog not-relative to pkg-dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com> --- osc/commandline.py | 77 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 8d046122dfeea90255fb25348f5281c41b227294..d96c197a72255a8d2d9a442a9405d7accba0e844 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6132,6 +6132,10 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='get log start or end from the offset') @cmdln.option('-s', '--strip-time', action='store_true', help='strip leading build time from the log') + @cmdln.option('-O', '--all-packages', action='store_true', + help='Show buildlog for all packages of project') + @cmdln.option('-S', '--status', action='store', metavar='STATUS', + help='Only show build of packages with STATUS') def do_buildlog(self, subcmd, opts, *args): """ Shows the build log of a package @@ -6147,31 +6151,54 @@ Please submit there instead, or use --nodevelproject to force direct submission. results' output. If the buildlog url is used buildlog command has the same behavior as remotebuildlog. + buildlog PROJECT PACKAGE [REPOSITORY] [ARCH] + buildlog PROJECT [REPOSITORY] [ARCH] + buildlog PACKAGE [REPOSITORY] [ARCH] buildlog [REPOSITORY ARCH | BUILDLOGURL] """ project = package = repository = arch = None apiurl = self.get_api_url() + repo_arg_offset = 0 if len(args) == 1 and args[0].startswith('http'): apiurl, project, package, repository, arch = parse_buildlogurl(args[0]) else: - project = store_read_project(Path.cwd()) - package = store_read_package(Path.cwd()) - if len(args) == 1: + cwd = Path.cwd() + if is_project_dir(cwd) or is_package_dir(cwd): + project = store_read_project(cwd) + if len(args) > 2: + project = args[0] + package = args[1] + repo_arg_offset = 2 + if len(args) >= 1: + if opts.all_packages: + project = args[0] + repo_arg_offset = 1 + else: + if not package and is_project_dir(cwd): + package = args[0] + prj = Project(cwd) + if package not in prj.pacs_avialable: + raise oscerr.WrongArgs(f'Package {package} doesn\'t exist in {project}') + repo_arg_offset = 1 + if not package and is_package_dir(cwd): + package = store_read_package(cwd) + if len(args) - repo_arg_offset == 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] + repository = args[repo_arg_offset] arch = osc_build.hostarch - elif len(args) < 2: + elif len(args) - repo_arg_offset < 2: self.print_repos() - elif len(args) > 2: + elif len(args) - repo_arg_offset > 2: + print(len(args), repo_arg_offset, project, package) raise oscerr.WrongArgs('Too many arguments.') else: - repository = args[0] - arch = args[1] + repository = args[0 + repo_arg_offset] + arch = args[1 + repo_arg_offset] if opts.multibuild_package: package = package + ":" + opts.multibuild_package @@ -6196,7 +6223,39 @@ Please submit there instead, or use --nodevelproject to force direct submission. elif opts.offset: offset = int(opts.offset) strip_time = opts.strip_time or conf.config['buildlog_strip_time'] - print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last, opts.lastsucceeded) + + if opts.all_packages: + self.print_buildl_prj_pkgs(apiurl, project, + repository, arch, offset, + strip_time, opts.last, opts.lastsucceeded, opts.status) + else: + print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last, opts.lastsucceeded) + + def print_buildl_prj_pkgs(self, + apiurl: str, + prj: str, + repository: str, + arch: str, + offset=0, + strip_time=False, + last=False, + lastsucceeded=False, + status='succeeded' + ): + r = [] + pkgs = [] + for results in get_package_results(apiurl, prj, + None, + repository, + arch): + for res, is_multi in result_xml_to_dicts(results): + if res['code'] == status: + pkgs.append(res['package']) + for pkg in pkgs: + with open(f'{prj}:{pkg}.log', 'w+b') as pkg_log_file: + print_buildlog(apiurl, prj, pkg, + repository, arch, + offset, strip_time, None, None, pkg_log_file) def print_repos(self, repos_only=False, exc_class=oscerr.WrongArgs, exc_msg='Missing arguments', project=None): wd = Path.cwd()
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor