summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Andres <ma@suse.de>2007-12-05 16:11:11 +0000
committerMichael Andres <ma@suse.de>2007-12-05 16:11:11 +0000
commitaebe9f09807b64704bb83360c2c4bd5613f41f50 (patch)
tree618e1ed39dfc7f7af47b526668c3852a3ec55046 /examples
parentbd560d58004ff8b33c8180529fe469879d98059a (diff)
downloadlibzypp-bindings-aebe9f09807b64704bb83360c2c4bd5613f41f50.tar.gz
libzypp-bindings-aebe9f09807b64704bb83360c2c4bd5613f41f50.tar.bz2
libzypp-bindings-aebe9f09807b64704bb83360c2c4bd5613f41f50.zip
add "zypper lu" in python
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/python/list_updates.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/python/list_updates.py b/examples/python/list_updates.py
new file mode 100755
index 0000000..2fac052
--- /dev/null
+++ b/examples/python/list_updates.py
@@ -0,0 +1,39 @@
+#! /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("/") )
+
+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.addResolvables( Z.target().resolvables(), True )
+
+# currently not swigged
+Z.applyLocks()
+Z.resolver().establishPool();
+
+print 'List Upadtes:'
+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() )
+