On Wednesday 08 September 2010 16:01:36 Ricardo Cruz wrote:
Hi there,
I was coding a python test case for this, but I can't seem to be able to initialize zypp with the local RPM database.
import zypp _zypp = zypp.ZYppFactory_instance().getZYpp() _target = _zypp.initializeTarget(zypp.Pathname(" ? ")) (...) _pool = _zypp.pool() print "pool size:", _pool.size() # zero :-(
What string should I pass to _zypp.initializeTarget() ?
The root of your system. Usually '/', unless you use --root.
I have tried to dig up yast2 code on this, but couldn't
Yast is too confuising ;). Try zypper or some of the tests/examples in the libzypp git.
pin down where initialization of the local database gets done, and other sources weren't more successful.
See the attached example. Slightly modified from git://gitorious.org/opensuse/libzypp-bindings.git (examples/python). Beware, the examples are pretty outdated but at least list_resolvables works. (patches/suggestions are wellcome ;) I added an onSystemByUser call as you asked for some 'p.installedBySolver' in the previous mail. Since libzypp-7.5.0: + /** Whether this is known to be installed on behalf of a user request. + * \note This is a hint guessed by evaluating an available install history. + * Returns \c false for non-system (uninstalled) solvables, or if no history + * is available. + */ + bool onSystemByUser() const; -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres ZYPP Development ma@suse.de SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+