summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorArvin Schnell <aschnell@suse.de>2007-09-25 14:41:52 +0000
committerArvin Schnell <aschnell@suse.de>2007-09-25 14:41:52 +0000
commitcd7a28cb24b5b1558a5e54806143453ed235425c (patch)
treeb16b078373084f45895301c3338baf8536e3078b /examples
parent7ca448153a21e34bce24af964c84d59c7efd4dc9 (diff)
downloadlibzypp-bindings-cd7a28cb24b5b1558a5e54806143453ed235425c.tar.gz
libzypp-bindings-cd7a28cb24b5b1558a5e54806143453ed235425c.tar.bz2
libzypp-bindings-cd7a28cb24b5b1558a5e54806143453ed235425c.zip
- exception now also in Python
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/python/exception.py33
-rwxr-xr-xexamples/ruby/exception.rb4
2 files changed, 35 insertions, 2 deletions
diff --git a/examples/python/exception.py b/examples/python/exception.py
new file mode 100755
index 0000000..4d65b64
--- /dev/null
+++ b/examples/python/exception.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+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)
+
+repo_info = RepoInfo()
+
+repo_info.setAlias("factorytest")
+repo_info.setName("Test Repo for Factory.")
+repo_info.setEnabled(True)
+repo_info.setAutorefresh(False)
+repo_info.addBaseUrl(Url("file:///tmp/does-not-exist"))
+
+try:
+ repo_manager.addRepository(repo_info)
+ repo_manager.refreshMetadata(repo_info)
+ repo_manager.buildCache(repo_info)
+except RuntimeError, strerror:
+ print "RuntimeError"
+ print strerror
+else:
+ print "Oh, no exception"
+
diff --git a/examples/ruby/exception.rb b/examples/ruby/exception.rb
index 95028fe..346d2d3 100755
--- a/examples/ruby/exception.rb
+++ b/examples/ruby/exception.rb
@@ -20,7 +20,7 @@ repo_info.set_alias("factorytest")
repo_info.set_name("Test Repo for Factory.")
repo_info.set_enabled(true)
repo_info.set_autorefresh(false)
-repo_info.add_base_url("file:///tmp/does-not-exist")
+repo_info.add_base_url(Url.new("file:///tmp/does-not-exist"))
begin
repo_manager.add_repository(repo_info)
@@ -28,7 +28,7 @@ begin
repo_manager.build_cache(repo_info)
rescue ZYppException => e
puts "ZYppException caught"
- puts e.to_s
+ puts e
else
puts "Oh, no exception"
end