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): 3.2.22 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:
at the moment I have no problems with your patch but - why are you importing yummain as a module?
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
I'm using it to install packages in another python module...
Why not use the yum.yumbase class? You'll get less garbage spewed on the console/stdout and you can control it better.
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.
Also take a look at: http://yum.baseurl.org/wiki/YumCodeSnippets and http://yum.baseurl.org/wiki/5MinuteExamples
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?
no, nothing since the last build has gone in. But why would we add a plugin hook there?
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.
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 ?
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: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
.23 solves all this, I think ... although you need a newer aliases.