Author: mlandres Date: Wed Dec 5 18:45:14 2007 New Revision: 8039 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8039&view=rev Log: update examples Added: trunk/libzypp-bindings/examples/python/install_updates_dryrun.py (with props) Modified: trunk/libzypp-bindings/examples/python/list_updates.py trunk/libzypp-bindings/swig/ResStatus.i trunk/libzypp-bindings/swig/ResTraits.i trunk/libzypp-bindings/swig/ZYppCommitResult.i Added: trunk/libzypp-bindings/examples/python/install_updates_dryrun.py URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/install_updates_dryrun.py?rev=8039&view=auto ============================================================================== --- trunk/libzypp-bindings/examples/python/install_updates_dryrun.py (added) +++ trunk/libzypp-bindings/examples/python/install_updates_dryrun.py Wed Dec 5 18:45:14 2007 @@ -0,0 +1,60 @@ +#! /usr/bin/python + +import os, sys, types, string, re + +try: + import zypp +except ImportError: + print 'Dummy Import Error: Unable to import zypp bindings' + +print 'Reading repositories...' + +Z = zypp.ZYppFactory_instance().getZYpp() + +Z.initializeTarget( zypp.Pathname("/") ) +Z.addResolvables( Z.target().resolvables(), True ) + +repoManager = zypp.RepoManager() +repos = repoManager.knownRepositories() + +for repo in repos: + if repo.enabled() and repo.autorefresh(): + try: + repoManager.refreshMetadata(repo, zypp.RepoManager.RefreshIfNeeded) # or RefreshIfNeeded == 0 + except: + repoManager.buildCache( repo ) + + Z.addResolvables( repoManager.createFromCache( repo ).resolvables()) + +Z.applyLocks() +Z.resolver().establishPool(); + +# +# Does not to check and apply updates for the update stack first. +# +print 'List Upadtes:' +for item in Z.pool().byKindIterator(zypp.KindOfPatch()): + if item.status().isInstalled(): + continue + if item.status().isNeeded(): + if not item.status().setTransact( True, zypp.ResStatus.USER ): + raise "Error set transact: %s" % item + resolvable = zypp.asKindPatch( item ) + print '%s | %s-%s | %s | %s' % (resolvable.repository().info().alias(), resolvable.name(), resolvable.edition(), resolvable.category(), item.status() ) + +if not Z.resolver().resolvePool(): + raise "Solver Error" + +for item in Z.pool(): + if item.status().transacts(): + print item + +# +# dryRun! +# +policy = zypp.ZYppCommitPolicy() +policy.dryRun( True ) +policy.syncPoolAfterCommit( False ) + +result = Z.commit( policy ) +print result Modified: trunk/libzypp-bindings/examples/python/list_updates.py URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/list_updates.py?rev=8039&r1=8038&r2=8039&view=diff ============================================================================== --- trunk/libzypp-bindings/examples/python/list_updates.py (original) +++ trunk/libzypp-bindings/examples/python/list_updates.py Wed Dec 5 18:45:14 2007 @@ -12,6 +12,7 @@ Z = zypp.ZYppFactory_instance().getZYpp() Z.initializeTarget( zypp.Pathname("/") ) +Z.addResolvables( Z.target().resolvables(), True ) repoManager = zypp.RepoManager() repos = repoManager.knownRepositories() @@ -25,15 +26,11 @@ Z.addResolvables( repoManager.createFromCache( repo ).resolvables()) -Z.addResolvables( Z.target().resolvables(), True ) - -# currently not swigged Z.applyLocks() Z.resolver().establishPool(); -print 'List Upadtes:' +print 'List Updates:' for item in Z.pool().byKindIterator(zypp.KindOfPatch()): if item.status().isNeeded(): resolvable = zypp.asKindPatch( item ) print '%s | %s-%s | %s | %s' % (resolvable.repository().info().alias(), resolvable.name(), resolvable.edition(), resolvable.category(), item.status() ) - Modified: trunk/libzypp-bindings/swig/ResStatus.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ResStatus.i?rev=8039&r1=8038&r2=8039&view=diff ============================================================================== --- trunk/libzypp-bindings/swig/ResStatus.i (original) +++ trunk/libzypp-bindings/swig/ResStatus.i Wed Dec 5 18:45:14 2007 @@ -395,4 +395,4 @@ str << *self; return str.str(); } -} \ No newline at end of file +} Modified: trunk/libzypp-bindings/swig/ResTraits.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ResTraits.i?rev=8039&r1=8038&r2=8039&view=diff ============================================================================== --- trunk/libzypp-bindings/swig/ResTraits.i (original) +++ trunk/libzypp-bindings/swig/ResTraits.i Wed Dec 5 18:45:14 2007 @@ -18,6 +18,12 @@ %template(ResObject_constPtr) intrusive_ptr<const ResObject>; %template(ResObject_Ptr) intrusive_ptr<ResObject>; +// Common definitions for all Resolvable types +// - *_Ptr and *_constPtr +// - isKind* to test whether a ResObject/PoolItem is +// of a specific kind. +// - asKind* to convert a ResObject/PoolItem into a +// specific *_constPtr. %define %STUFF(X) typedef intrusive_ptr<const X> X##_constPtr; typedef intrusive_ptr<X> X##_Ptr; @@ -37,12 +43,12 @@ { return isKind<X>( p ); } inline bool isKind##X( const PoolItem & p ) { return isKind<X>( p.resolvable() ); } - inline X::constPtr asKind##X( const Resolvable::constPtr & p ) { return asKind<X>( p ); } inline X::constPtr asKind##X( const PoolItem & p ) { return asKind<X>( p.resolvable() ); } } + #if defined(SWIGPYTHON) %pythoncode { Modified: trunk/libzypp-bindings/swig/ZYppCommitResult.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/ZYppCommitResult.i?rev=8039&r1=8038&r2=8039&view=diff ============================================================================== --- trunk/libzypp-bindings/swig/ZYppCommitResult.i (original) +++ trunk/libzypp-bindings/swig/ZYppCommitResult.i Wed Dec 5 18:45:14 2007 @@ -23,4 +23,14 @@ * list of kind:source resolvables remaining (due to wrong media) **/ PoolItemList _srcremaining; - }; \ No newline at end of file + }; + +%extend ZYppCommitResult +{ + std::string asString() const + { + std::ostringstream str; + str << *self; + return str.str(); + } +} -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org