[zypp-devel] jippie - my pool gets listed! Q: nicer output ?
Moin moin!
for item in pool: ... print item.string() ... U__s_(2)ConsoleKit-x11-0.2.10-12.3.i586(software) [...] U__s_(546)hicolor-icon-theme-0.10-63.5.noarch(software)
Jippie - it works with zypp from svn. So just one more question: can i somehow only query * packagename * version * repoalias or do i need to extract this. I mean e.g. for item in pool: item.name() item.version() item.repoalias() Best regards Jan-Simon -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Jan-Simon Möller wrote:
Moin moin!
for item in pool: ... print item.string() ... U__s_(2)ConsoleKit-x11-0.2.10-12.3.i586(software) [...] U__s_(546)hicolor-icon-theme-0.10-63.5.noarch(software)
Jippie - it works with zypp from svn. So just one more question: can i somehow only query
* packagename * version * repoalias
or do i need to extract this.
nope.. that would be shame for libzypp :O) This 'item' is probably a zypp::ui::Selectable (don't know what's the Python way of saying this), right? then 'item.name()' should work.
item.version()
This is a bit more complex: Resolvable::edition() is what you want, but a Selectable is a group of all available packages (well.. resolvables) with the same name and kind. Look at the Selectable interface to see what functions are there to get the Resolvables: available{Begin,End} - gets all of Selectable's Resolvables (as PoolItems!) installed{Begin,End} - gets only the installed ones theObj - gets the object with newest version and best architecture among the available objects candidateObj - the same as theObj :O) installedObj - the first of the installed objects a PoolItem contains ResStatus and a Resolvable, a Resolvable is a Package, Patch, Pattern, or Product (look at the doxygen docs, or c++ header docs).
item.repoalias()
Each Resolvable contains a reference to the Repository of origin and the associated RepoInfo object. You get the alias from that one. HTH, jano -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Am Donnerstag 04 September 2008 16:24:17 schrieb Jano Kupec:
Jan-Simon Möller wrote:
Moin moin!
for item in pool: ... print item.string() ... U__s_(2)ConsoleKit-x11-0.2.10-12.3.i586(software) [...] U__s_(546)hicolor-icon-theme-0.10-63.5.noarch(software)
Jippie - it works with zypp from svn. So just one more question: can i somehow only query
* packagename * version * repoalias
or do i need to extract this.
nope.. that would be shame for libzypp :O)
This 'item' is probably a zypp::ui::Selectable (don't know what's the Python way of saying this), right? then 'item.name()' should work.
> item.name() doesn't work.
[...]
I couldn't sleep, so i looked at some snippets in satsolver-bindings.
What works now is this (don't blame me, I'm learning ;) ): (all in python-bindings)
Import the remote repo with libzypp. Load the solv file with satsolver. Get the values i want.
It looks like this:
import zypp
import satsolver
zy = zypp.ZYppFactory_instance().getZYpp()
mytemppath = zypp.Pathname( "/tmp/a" )
zy.initializeTarget( mytemppath )
myrepoinfo = zypp.RepoInfo()
myrepoinfo.addBaseUrl( zypp.Url( "http://localhost/software/base_factory" )) # local obs instance output
myrepoinfo.setAlias( "software" )
myrepoinfo.setEnabled( True )
myrepoinfo.setType( zypp.RepoType.RPMMD )
myrepoinfo.setGpgCheck( False ) # not yet implemented . i would need this atm : ZYPP_KEYRING_DEFAULT_ACCEPT_ALL=1
myrepomanageroptions = zypp.RepoManagerOptions( mytemppath )
myrepomanager = zypp.RepoManager( myrepomanageroptions )
myrepomanager.addRepository( myrepoinfo )
myrepomanager.refreshMetadata( myrepoinfo )
myrepomanager.buildCache( myrepoinfo )
myrepomanager.loadFromCache( myrepoinfo )
for item in pool:
print item.string() # e.g. U__s_(213)cairo-doc-1.4.14-20.2.i586(software)
print item # e.g.
On Fri, Sep 05, Jan-Simon M?ller wrote:
for item in pool: print item.string() # e.g. U__s_(213)cairo-doc-1.4.14-20.2.i586(software) print item # e.g.
> # i had no idea how to proceed from here /me blind watching doxygen pages and stuff like ^^^^^ # then i looked at satsolver and discovered /tmp/a/var/cache/zypp/solv/software/solv # so if someone could show me how to do this with libzypp - he would be my hero of the day ;)
PoolItem combines Solvable and Status: item.resolvable() // Type zypp::ResObject_Ptr item.resolvable().name() item.resolvable().edition() .arch() .provides() .summary() .description() .repoInfo() ... (see ResObject and Resolvable) This is how it should work, but currently the bindings are messed up again. ;( I can't check if it realy does. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Am Freitag 05 September 2008 14:14:57 schrieb Michael Andres:
PoolItem combines Solvable and Status: Right ... which is good ;)
item.resolvable() // Type zypp::ResObject_Ptr
item.resolvable().name() item.resolvable().edition() .arch() .provides() .summary() .description() .repoInfo() ...
But i need "Group" which is not available by this.
(see ResObject and Resolvable) This is how it should work, but currently the bindings are messed up again. ;( I can't check if it realy does. I'll do :D.
Could it be zypp/sat/ is missing in the bindings ? std::string zypp::sat::Solvable::lookupStrAttribute( const SolvAttr & attr ) const would give me access to the other values, right ? Thanks! Best regards, Jan-Simon -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Fri, Sep 05, Jan-Simon M?ller wrote:
Am Freitag 05 September 2008 14:14:57 schrieb Michael Andres:
PoolItem combines Solvable and Status: Right ... which is good ;)
item.resolvable() // Type zypp::ResObject_Ptr
item.resolvable().name() item.resolvable().edition() .arch() .provides() .summary() .description() .repoInfo() ...
But i need "Group" which is not available by this.
(see ResObject and Resolvable)
ResObject is the base class providing attributes common to Package, Pattern, Patch and Product. You can use e.g zypp.isKindPackage( item ) to test whether some item is a Package. And zypp.asKindPackage( item ) to return the corresponding Package that gives access to all Package attributes: ( This requires libzypp / libzypp-binding from SVN revision 10956 ) +------------------------------------------------------------------+ #! /usr/bin/python import zypp Z = zypp.ZYppFactory_instance().getZYpp() Z.initializeTarget( zypp.Pathname("/") ) Z.target().load(); repoManager = zypp.RepoManager() repos = repoManager.knownRepositories() for repo in repos: if not repo.enabled(): continue if not repoManager.isCached( repo ): repoManager.buildCache( repo ) repoManager.loadFromCache( repo ); print "Items: %d" % ( Z.pool().size() ) for item in Z.pool(): if item.status().isInstalled(): t = "i" else: t = "*" print "%s %s:%s-%s.%s\t(%s)" % ( t, item.kind(), item.name(), item.edition(), item.arch(), item.repoInfo().alias() ) if zypp.isKindPackage( item ): print " Group: %s" %(zypp.asKindPackage( item ).group( ) ) +------------------------------------------------------------------+ -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (3)
-
Jan-Simon Möller
-
Jano Kupec
-
Michael Andres