[Yum-devel] Yum API: logging level, configuration, non-root questions
Richard W.M. Jones
rjones at redhat.com
Mon Dec 6 09:30:02 UTC 2010
On Sun, Dec 05, 2010 at 08:45:43PM -0500, seth vidal wrote:
> On Sun, 2010-12-05 at 17:19 +0000, Richard W.M. Jones wrote:
> > I'm using the snippet of code below in order to resolve dependencies
> > from a list of packages, and it works fine.
> >
> > However there are some problems I can't work out how to fix:
> >
> > (1) How do I emulate the '--quiet' command line option, ie. make it so
> > that the yum libraries don't send lots of messages to stdout (which
> > conflicts with the list that I want to write to stdout).
>
>
> you probably want to use preconf so:
>
> yb = yum.YumBase()
> yb.preconf.debuglevel=0
> yb.preconf.errorlevel=0
>
>
>
> > (2) When I run this as non-root, it works, *unless* the yum repo is
> > not up to date. If the yum repo is not up to date then it fails
> > because it tries to download and overwrite package lists in a
> > root-owned directory. Now obviously other tools eg. yumdownloader
> > work fine as non-root. How can I fix that?
>
> yb.setCacheDir()
>
> will do all you want
>
> >
> > (3) How can I make it use a non-default location for the yum
> > configuration (instead of /etc/yum.conf /etc/yum.repos.d/*)?
> > Alternately emulate --disablerepo/--enablerepo on the command line?
>
> Do you want a different set of config files or a different set of repos
> entirely?
>
> like above
> yb.preconf.fn = '/path/to/my/conf/file'
>
> and then specifiy the .repos.d path in the conf file you made.
Excellent, that fixes all the problems. Thanks for the help.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
More information about the Yum-devel
mailing list