Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1667423 - The doc/examples/install_plugin.py leads to traceback
Summary: The doc/examples/install_plugin.py leads to traceback
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Marek Blaha
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-18 12:59 UTC by Jan Pazdziora
Modified: 2019-02-21 02:56 UTC (History)
10 users (show)

Fixed In Version: dnf-4.1.0-1.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-21 02:56:58 UTC
Type: Bug


Attachments (Terms of Use)

Description Jan Pazdziora 2019-01-18 12:59:56 UTC
Description of problem:

The doc/examples/install_plugin.py example does not work out of box.

Version-Release number of selected component (if applicable):

Testing on Fedora rawhide with dnf-4.0.10-1.fc30.noarch.

How reproducible:

Deterministic.

Steps to Reproduce:
1. Copy doc/examples/install_plugin.py from dnf master to /usr/lib/python3.7/site-packages/dnf-plugins/foo.py
2. Try to test with dnf foo zsh

Actual results:

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 95, in _main
    cli.configure(list(map(ucd, args)), option_parser())
  File "/usr/lib/python3.7/site-packages/dnf/cli/cli.py", line 940, in configure
    self.optparser.print_help(self.command)
  File "/usr/lib/python3.7/site-packages/dnf/cli/option_parser.py", line 407, in print_help
    cp = self._command_parser(command)
  File "/usr/lib/python3.7/site-packages/dnf/cli/option_parser.py", line 341, in _command_parser
    command.set_argparser(self)
  File "/usr/lib/python3.7/site-packages/dnf-plugins/foo.py", line 29, in set_argparser
    parser.add_argument('package', nargs='+', metavar=_('PACKAGE'),
NameError: name '_' is not defined

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 95, in _main
    cli.configure(list(map(ucd, args)), option_parser())
  File "/usr/lib/python3.7/site-packages/dnf/cli/cli.py", line 940, in configure
    self.optparser.print_help(self.command)
  File "/usr/lib/python3.7/site-packages/dnf/cli/option_parser.py", line 407, in print_help
    cp = self._command_parser(command)
  File "/usr/lib/python3.7/site-packages/dnf/cli/option_parser.py", line 341, in _command_parser
    command.set_argparser(self)
  File "/usr/lib/python3.7/site-packages/dnf-plugins/foo.py", line 30, in set_argparser
    action=OptionParser.ParseSpecGroupFileCallback,
NameError: name 'OptionParser' is not defined

Last metadata expiration check: 1:46:16 ago on Fri 18 Jan 2019 05:56:29 AM EST.
Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.7/site-packages/dnf/cli/cli.py", line 1107, in run
    return self.command.run()
  File "/usr/lib/python3.7/site-packages/dnf-plugins/foo.py", line 44, in run
    self.base.package_install(self.base.add_remote_rpms(self.opts.package, strict=False))
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 1891, in package_install
    q = self.sack.query()._nevra(pkg.name, pkg.evr, pkg.arch)
AttributeError: 'list' object has no attribute 'name'

Expected results:

No errors, the example does something useful.

Additional info:

Fix for the first two tracebacks is in https://github.com/rpm-software-management/dnf/pull/1304.

But I have no idea how the self.base.package_install(self.base.add_remote_rpms(self.opts.package, strict=False)) line should work or what it's supposed to do.

Comment 2 Fedora Update System 2019-02-18 10:15:26 UTC
libcomps-0.1.10-2.fc29 libdnf-0.26.0-1.fc29 dnf-plugins-core-4.0.4-1.fc29 dnf-plugins-extras-4.0.2-1.fc29 dnf-4.1.0-1.fc29 librepo-1.9.4-1.fc29 createrepo_c-0.12.1-1.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-1fccede810

Comment 3 Fedora Update System 2019-02-19 06:27:25 UTC
createrepo_c-0.12.1-1.fc29, dnf-4.1.0-1.fc29, dnf-plugins-core-4.0.4-1.fc29, dnf-plugins-extras-4.0.2-1.fc29, libcomps-0.1.10-2.fc29, libdnf-0.26.0-1.fc29, librepo-1.9.4-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-1fccede810

Comment 4 Fedora Update System 2019-02-21 02:56:58 UTC
createrepo_c-0.12.1-1.fc29, dnf-4.1.0-1.fc29, dnf-plugins-core-4.0.4-1.fc29, dnf-plugins-extras-4.0.2-1.fc29, libcomps-0.1.10-2.fc29, libdnf-0.26.0-1.fc29, librepo-1.9.4-1.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.