diff options
author | Michael Andres <ma@suse.de> | 2009-02-20 14:58:45 +0100 |
---|---|---|
committer | Michael Andres <ma@suse.de> | 2009-02-20 14:59:47 +0100 |
commit | 2ec97ca1930673f6dbf424678024393e349fb9b9 (patch) | |
tree | 4ed850ee7837a796e8aadb0ee58844490393e27f /examples | |
parent | ad301c5ca1888071ea142ef8e7dda0829c3c954c (diff) | |
download | libzypp-bindings-2ec97ca1930673f6dbf424678024393e349fb9b9.tar.gz libzypp-bindings-2ec97ca1930673f6dbf424678024393e349fb9b9.tar.bz2 libzypp-bindings-2ec97ca1930673f6dbf424678024393e349fb9b9.zip |
fix outdated python examples
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/python/callbacks.py | 44 | ||||
-rwxr-xr-x | examples/python/exception.py | 12 | ||||
-rwxr-xr-x | examples/python/install_updates_dryrun.py | 42 | ||||
-rwxr-xr-x | examples/python/list_available_resolvables.py | 25 | ||||
-rwxr-xr-x | examples/python/list_installed_resolvables.py | 14 | ||||
-rwxr-xr-x | examples/python/list_target_resolvables.py | 25 | ||||
-rwxr-xr-x | examples/python/list_updates.py | 36 |
7 files changed, 21 insertions, 177 deletions
diff --git a/examples/python/callbacks.py b/examples/python/callbacks.py deleted file mode 100755 index 89149de..0000000 --- a/examples/python/callbacks.py +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/python -import zypp - -# --------------------------------------------------------- - -def myProgress( val ): - print "myProgress %d" % val - return True - -rec = zypp.ScanRpmDbReceive() -rec.set_pymethod( myProgress ) - -# --------------------------------------------------------- - -Z = zypp.ZYppFactory_instance().getZYpp() - -if True: - Z.initializeTarget( zypp.Pathname("/Local/ROOT") ) - Z.addResolvables( Z.target().resolvables(), True ); - -if False: - repoManager = zypp.RepoManager() - repos = repoManager.knownRepositories() - for repo in repos: - if not repo.enabled(): - continue - if not repoManager.isCached( repo ): - repoManager.buildCache( repo ) - Z.addResolvables( repoManager.createFromCache( repo ).resolvables() ) - -print "Items: %d" % ( Z.pool().size() ) - -if False: - for item in Z.pool(): - if item.status().isInstalled(): - t = "i" - else: - t = "*" - print "%s %s:%s-%s.%s\t(%s)" % ( t, - item.resolvable().kind(), - item.resolvable().name(), - item.resolvable().edition(), - item.resolvable().arch(), - item.resolvable().repository().info().alias() ) diff --git a/examples/python/exception.py b/examples/python/exception.py index 4d65b64..9b7e6ec 100755 --- a/examples/python/exception.py +++ b/examples/python/exception.py @@ -2,16 +2,8 @@ from zypp import TmpDir, RepoManagerOptions, RepoManager, RepoInfo, Url -tmp_cache_path = TmpDir() -tmp_raw_cache_path = TmpDir() -tmp_known_repos_path = TmpDir() - -opts = RepoManagerOptions() -opts.repoCachePath = tmp_cache_path.path() -opts.repoRawCachePath = tmp_raw_cache_path.path() -opts.knownReposPath = tmp_known_repos_path.path() - -repo_manager = RepoManager(opts) +tmp_root=TmpDir() +repo_manager = RepoManager(RepoManagerOptions(tmp_root.path())) repo_info = RepoInfo() diff --git a/examples/python/install_updates_dryrun.py b/examples/python/install_updates_dryrun.py index f3fb10c..05e7c72 100755 --- a/examples/python/install_updates_dryrun.py +++ b/examples/python/install_updates_dryrun.py @@ -8,50 +8,46 @@ 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 ) +Z.target().load(); 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(); + if not repo.enabled(): + continue + if not repoManager.isCached( repo ): + repoManager.buildCache( repo ) + repoManager.loadFromCache( repo ); +print "Items: %d" % ( Z.pool().size() ) # # 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() ) +Z.resolver().resolvePool() + +for item in Z.pool(): + if not zypp.isKindPatch( item ): + continue + if item.isBroken(): + 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.repoInfo().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 + print '%s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() ) # # dryRun! # + policy = zypp.ZYppCommitPolicy() policy.dryRun( True ) policy.syncPoolAfterCommit( False ) diff --git a/examples/python/list_available_resolvables.py b/examples/python/list_available_resolvables.py deleted file mode 100755 index 39f5f38..0000000 --- a/examples/python/list_available_resolvables.py +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/python -import zypp - -Z = zypp.ZYppFactory_instance().getZYpp() - -repoManager = zypp.RepoManager() -repos = repoManager.knownRepositories() - -for repo in repos: - if not repo.enabled(): - continue - if not repoManager.isCached( repo ): - repoManager.buildCache( repo ) - - Z.addResolvables( repoManager.createFromCache( repo ).resolvables() ) - - -print "Available items: %d" % ( Z.pool().size() ) - -for item in Z.pool(): - print "* %s:%s-%s.%s\t(%s)" % ( item.resolvable().kind(), - item.resolvable().name(), - item.resolvable().edition(), - item.resolvable().arch(), - item.resolvable().repository().info().alias() ) diff --git a/examples/python/list_installed_resolvables.py b/examples/python/list_installed_resolvables.py deleted file mode 100755 index f4ded7e..0000000 --- a/examples/python/list_installed_resolvables.py +++ /dev/null @@ -1,14 +0,0 @@ -#! /usr/bin/python -import zypp - -Z = zypp.ZYppFactory_instance().getZYpp() -Z.initializeTarget( zypp.Pathname("/") ) -Z.addResolvables( Z.target().resolvables(), True ); - -print "Installed items: %d" % ( Z.pool().size() ) - -for item in Z.pool(): - print "i %s:%s-%s.%s" % ( item.resolvable().kind(), - item.resolvable().name(), - item.resolvable().edition(), - item.resolvable().arch() ) diff --git a/examples/python/list_target_resolvables.py b/examples/python/list_target_resolvables.py deleted file mode 100755 index 27d9b6f..0000000 --- a/examples/python/list_target_resolvables.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python - -from zypp import ZYppFactory, Pathname, Dep - -z = ZYppFactory.instance().getZYpp() -print z - -z.initializeTarget(Pathname("/")) - -r = z.target().resolvables() -print r - -# TODO: display resolvables - -p = r.haha() -print p -print p.name() -print p.summary() - -d = p.dep(Dep.PROVIDES) -print d - -x = d.haha() -print x - diff --git a/examples/python/list_updates.py b/examples/python/list_updates.py deleted file mode 100755 index 3f899d4..0000000 --- a/examples/python/list_updates.py +++ /dev/null @@ -1,36 +0,0 @@ -#! /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(); - -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() ) |