Bug 496878 - yummain.py does not work when imported as module, the arguments passed to it are ignored.
yummain.py does not work when imported as module, the arguments passed to it ...
Product: Fedora
Classification: Fedora
Component: yum (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Seth Vidal
Fedora Extras Quality Assurance
: Reopened
Depends On:
  Show dependency treegraph
Reported: 2009-04-21 10:25 EDT by Martin Gracik
Modified: 2014-01-21 18:09 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-07-10 12:13:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch fixing the arguments passing, when used as module (919 bytes, patch)
2009-04-21 10:25 EDT, Martin Gracik
no flags Details | Diff

  None (edit)
Description Martin Gracik 2009-04-21 10:25:47 EDT
Created attachment 340536 [details]
Patch fixing the arguments passing, when used as module

Description of problem:
yummain does not work when imported as module. The arguments passed to it are ignored.

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

How reproducible:
Import yummain as module, and run it's user_main function with some arguments.

Steps to Reproduce:
1. Run python interpreter
2. import yummain
3. yummain.user_main(['install', 'yum'], exit_code=True)

Actual results:
Error saying we need to give it a command.

Expected results:
Installation of the package provided in the args.

Additional info:
Comment 1 seth vidal 2009-04-21 10:30:44 EDT
at the moment I have no problems with your patch but - why are you importing yummain as a module?
Comment 2 seth vidal 2009-04-21 10:36:19 EDT
I've changed what your patch did to just invert what the if statement was saying.

However, I'm still confused why you're importing yummain
Comment 3 Martin Gracik 2009-04-21 11:00:26 EDT
I'm using it to install packages in another python module...
Comment 4 seth vidal 2009-04-21 11:07:07 EDT
Why not use the yum.yumbase class? You'll get less garbage spewed on the console/stdout and you can control it better.
Comment 5 Martin Gracik 2009-04-21 11:16:27 EDT
This yummain was already used in the code I got, and it looks simple, so I didn't change it. I think I'm not concerned about the console output. :)

But thanks for the tip, I will take a look at yumbase.
Comment 6 seth vidal 2009-04-21 11:23:12 EDT
Also take a look at:


Comment 7 James Antill 2009-04-23 12:33:09 EDT
 This change breaks yum-plugin-aliases, as that worked by altering sys.argv ... which isn't used now.

 Probably the best way to fix it is to add a plugin hook, did this get into F-11 GA?
Comment 8 seth vidal 2009-04-23 12:40:10 EDT
no, nothing since the last build has gone in.

But why would we add a plugin hook there?
Comment 9 James Antill 2009-04-23 13:29:39 EDT
 Well the way aliases currently works is directly altering sys.argv, which is then used by that parse_args().
 So we either add a plugin hook so that the aliases plugin can alter the args, find some way to default back to sys.argv[1:] again but allow Martin's code to work ... or just say aliases doesn't work anymore.
Comment 10 Martin Gracik 2009-04-24 03:48:25 EDT
If you don't send args parameter, or send None to setupYumConfig, it will use sys,argv[1:].
Do the aliases send args parameter, but still want it to use sys.argv ?
Comment 11 Bug Zapper 2009-06-09 10:18:39 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
Comment 12 James Antill 2009-07-10 12:13:14 EDT
.23 solves all this, I think ... although you need a newer aliases.

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