Bug 496878

Summary: yummain.py does not work when imported as module, the arguments passed to it are ignored.
Product: [Fedora] Fedora Reporter: Martin Gracik <mgracik>
Component: yumAssignee: Seth Vidal <skvidal>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: dmach, ffesti, james.antill, pmatilai, tim.lauridsen
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-07-10 16:13:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch fixing the arguments passing, when used as module none

Description Martin Gracik 2009-04-21 14:25:47 UTC
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:

Comment 1 seth vidal 2009-04-21 14:30:44 UTC
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 14:36:19 UTC
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 15:00:26 UTC
I'm using it to install packages in another python module...

Comment 4 seth vidal 2009-04-21 15:07:07 UTC
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 15:16:27 UTC
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 15:23:12 UTC
Also take a look at:
http://yum.baseurl.org/wiki/YumCodeSnippets

and

http://yum.baseurl.org/wiki/5MinuteExamples

Comment 7 James Antill 2009-04-23 16:33:09 UTC
 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 16:40:10 UTC
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 17:29:39 UTC
 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 07:48:25 UTC
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 14:18:39 UTC
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

Comment 12 James Antill 2009-07-10 16:13:14 UTC
.23 solves all this, I think ... although you need a newer aliases.