[Yum] Calling yum from python

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All,

I am trying to call yum from python. 
------------------------------------------------------------------------
---------
Following is the way I try to this [code-1]
------------------------------------------------------------------------
---------
#!/usr/bin/env python

import sys

sys.path.insert(0, "/usr/share/yum-cli")
import yummain
yummain.main("search bash".split())
------------------------------------------------------------------------
---------

But all I get is the usage message
------------------------------------------------------------------------
---------
You need to give some command

usage: yum [options] < update | install | info | remove | list |
    clean | provides | search | check-update | groupinstall |
    groupupdate | grouplist | groupinfo | groupremove |
    makecache | localinstall | erase | upgrade | whatprovides |
    localupdate | resolvedep | shell | deplist >

options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C                    run entirely from cache, don't update cache
....
...
------------------------------------------------------------------------
---------
If I try this instead [code-2]
------------------------------------------------------------------------
---------
#!/usr/bin/env python

import sys

sys.path.insert(0, "/usr/share/yum-cli")
import yummain

sys.argv=sys.argv + "search bash".split()
yummain.main(sys.argv[1:])
------------------------------------------------------------------------
---------
It works without any problem

Code-1 works with 2.2.2 and not with 2.4.3 or 2.9.0 (I get the usage
message). I think yummain uses sys.argv instead of using the list
passed.
Code-1 works with all the version, but I don't want to set or change the
argv. 

The objective is to get the functionality of yum from python code

Thanks for any help

Regards
Chandan Dutta Chowdhury

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux