Skip to content

package version parameter does not work for extended version numbers #161

@internetb

Description

@internetb

Describe the bug

`% python3 pcs_images_packages_read.py --package_id curl:8 --version_comparison lt

Testing Compute API Access ... done.

Searching for Package: (curl) Version: (8) Exact Match Name: (False) Version Comparison Operator: (lt)

Getting CI Images ...
Traceback (most recent call last):
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 255, in
ci_images_with_package = parse_images(ci_images, search_all_packages, args.package_type, args.exact_match_name, search_package_name, args.version_comparison, search_package_version)
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 171, in parse_images
if package_version_matches(search_comparison_operator, search_version, package['version']):
File "/Users/username/git/prismacloud-api-python/scripts/pcs_images_packages_read.py", line 82, in package_version_matches
package_semver = version.parse(package_version)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/packaging/version.py", line 52, in parse
return Version(version)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/packaging/version.py", line 197, in init
raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '7.61.1-25.el8_7.1'
`

It seems like using the :version capability breaks if you have any versions of the package with extended version numbers. I'm not certain of the breakpoint, but it seems like either the dash (-), or the underscore (_) might be the cause.

Expected behavior

Correctly parses the version number and returns results

Current behavior

Script crashes with above InvalidVersion error.

Possible solution

Improve parsing of versions.

Steps to reproduce

Provided above, assuming you have extended versions of the app in question.

Your Environment

  • git commit used (latest): 30ac4b6
  • Python Version used: Python 3.9.6
  • Operating System and version (desktop or mobile): MacOS 13.6 (22G120)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions