Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

results: Add support for --format for default text mode #1580

Merged

Conversation

marcosbc
Copy link
Contributor

@marcosbc marcosbc commented Jun 14, 2024

In this PR, we allow the --format option to work for osc results for the default text mode as well, not only --csv.

This workaround allows to resolve/workaround the following issues (by specifying the format in CSV):

Motivation

We want to be able to run osc results --watch using a specific format, with the same filtering options supported by default (e.g. multibuild packages, do not show excluded archs, etc.). This is not currently possible due to the limitations of the --csv option.

Context

The osc results command currently does not support any way of formatting the output, except when using the --csv option. However, this option is limited as it does not support --multibuild-package, and it shows all excluded packages by default (even if --show-excluded is not specified).

Examples

  • Format all packages:
$ osc results -A api.opensuse.org openSUSE:Factory opensuse-tumbleweed-image --repo=images \
    --format '%(repository)s %(package)s %(arch)s %(code)s %(state)s'
images opensuse-tumbleweed-image:docker x86_64 succeeded unpublished
images opensuse-tumbleweed-image:lxc x86_64 succeeded unpublished
images opensuse-tumbleweed-image:networkd x86_64 succeeded unpublished
  • Show also excluded packages:
$ osc results -A api.opensuse.org openSUSE:Factory opensuse-tumbleweed-image --repo=images \
    --format '%(repository)s %(package)s %(arch)s %(code)s %(state)s' --show-excluded
images opensuse-tumbleweed-image local excluded unpublished
images opensuse-tumbleweed-image:docker local excluded unpublished
images opensuse-tumbleweed-image:lxc local excluded unpublished
images opensuse-tumbleweed-image:networkd local excluded unpublished
images opensuse-tumbleweed-image x86_64 excluded unpublished
images opensuse-tumbleweed-image:docker x86_64 succeeded unpublished
images opensuse-tumbleweed-image:lxc x86_64 succeeded unpublished
images opensuse-tumbleweed-image:networkd x86_64 succeeded unpublished
images opensuse-tumbleweed-image i586 excluded unpublished
images opensuse-tumbleweed-image:docker i586 excluded unpublished
images opensuse-tumbleweed-image:lxc i586 excluded unpublished
images opensuse-tumbleweed-image:networkd i586 excluded unpublished
  • Show only results for a specific multibuild package:
$ osc results -A api.opensuse.org openSUSE:Factory opensuse-tumbleweed-image --repo=images \
    --format '%(repository)s %(package)s %(arch)s %(code)s %(state)s' --multibuild-package=docker
images opensuse-tumbleweed-image:docker x86_64 succeeded unpublished

@marcosbc
Copy link
Contributor Author

marcosbc commented Jun 14, 2024

Need to fix the output for the default scenario (when --format is not specified). I'm looking into it.

Edit: Fixed.

@pep8speaks
Copy link

pep8speaks commented Jun 14, 2024

Hello @marcosbc! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 6060:121: E501 line too long (142 > 120 characters)
Line 6141:121: E501 line too long (121 > 120 characters)

Line 4160:121: E501 line too long (160 > 120 characters)

Comment last updated at 2024-06-18 14:23:05 UTC

@dmach
Copy link
Contributor

dmach commented Jun 16, 2024

I cloned the sources and ran:

osc co openSUSE:Factory/cmake
cd openSUSE:Factory/cmake
../../../osc-wrapper.py results -M mini --csv

It ended up with an exception:

  File ".../osc/core.py", line 4175, in get_package_results
    xml = b''.join(show_results_meta(apiurl, project, package, *args, **kwargs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: show_results_meta() got an unexpected keyword argument 'multibuild_packages'

I'll look into this and possibly propose a fix.
I'm also trying to replace string formatting with a proper csv writer.

Copy link

codecov bot commented Jun 16, 2024

Codecov Report

Attention: Patch coverage is 10.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 32.37%. Comparing base (c8ee1c6) to head (7b99b5b).
Report is 112 commits behind head on master.

Current head 7b99b5b differs from pull request most recent head a501ed3

Please upload reports for the commit a501ed3 to get more accurate results.

Files Patch % Lines
osc/core.py 0.00% 6 Missing ⚠️
osc/commandline.py 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1580      +/-   ##
==========================================
+ Coverage   31.47%   32.37%   +0.90%     
==========================================
  Files         103      118      +15     
  Lines       19070    19668     +598     
==========================================
+ Hits         6002     6368     +366     
- Misses      13068    13300     +232     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dmach dmach force-pushed the osc-results-format-for-default-text-mode branch from b54fd83 to a5f2300 Compare June 18, 2024 13:55
@dmach dmach force-pushed the osc-results-format-for-default-text-mode branch from a5f2300 to a501ed3 Compare June 18, 2024 14:22
@dmach dmach merged commit 110ddaf into openSUSE:master Jun 18, 2024
31 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants