Bug 496878 - yummain.py does not work when imported as module, the arguments passed to it are ignored.
Summary: yummain.py does not work when imported as module, the arguments passed to it ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: yum
Version: 11
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Seth Vidal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-21 14:25 UTC by Martin Gracik
Modified: 2014-01-21 23:09 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-07-10 16:13:14 UTC
Type: ---
Embargoed:


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

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.


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