diff options
author | Michael Andres <ma@suse.de> | 2007-12-05 17:45:14 +0000 |
---|---|---|
committer | Michael Andres <ma@suse.de> | 2007-12-05 17:45:14 +0000 |
commit | fba86cb4c63e4845c320683400d7bea81a345497 (patch) | |
tree | b8a4d10806f7187466af387f2e7f574fb302d762 /examples | |
parent | aebe9f09807b64704bb83360c2c4bd5613f41f50 (diff) | |
download | libzypp-bindings-fba86cb4c63e4845c320683400d7bea81a345497.tar.gz libzypp-bindings-fba86cb4c63e4845c320683400d7bea81a345497.tar.bz2 libzypp-bindings-fba86cb4c63e4845c320683400d7bea81a345497.zip |
update examples
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/python/install_updates_dryrun.py | 60 | ||||
-rwxr-xr-x | examples/python/list_updates.py | 7 |
2 files changed, 62 insertions, 5 deletions
diff --git a/examples/python/install_updates_dryrun.py b/examples/python/install_updates_dryrun.py new file mode 100755 index 0000000..f3fb10c --- /dev/null +++ b/examples/python/install_updates_dryrun.py @@ -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 diff --git a/examples/python/list_updates.py b/examples/python/list_updates.py index 2fac052..3f899d4 100755 --- a/examples/python/list_updates.py +++ b/examples/python/list_updates.py @@ -12,6 +12,7 @@ print 'Reading repositories...' 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 @@ for repo in repos: 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() ) - |