Author: aschnell
Date: Tue Sep 25 16:41:52 2007
New Revision: 7371
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7371&view=rev
Log:
- exception now also in Python
Added:
trunk/libzypp-bindings/examples/python/exception.py (with props)
Modified:
trunk/libzypp-bindings/examples/ruby/exception.rb
trunk/libzypp-bindings/swig/python/python.i
Added: trunk/libzypp-bindings/examples/python/exception.py
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/python/exception.py?rev=7371&view=auto
==============================================================================
--- trunk/libzypp-bindings/examples/python/exception.py (added)
+++ trunk/libzypp-bindings/examples/python/exception.py Tue Sep 25 16:41:52 2007
@@ -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"
+
Modified: trunk/libzypp-bindings/examples/ruby/exception.rb
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/examples/ruby/exception.rb?rev=7371&r1=7370&r2=7371&view=diff
==============================================================================
--- trunk/libzypp-bindings/examples/ruby/exception.rb (original)
+++ trunk/libzypp-bindings/examples/ruby/exception.rb Tue Sep 25 16:41:52 2007
@@ -20,7 +20,7 @@
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 @@
repo_manager.build_cache(repo_info)
rescue ZYppException => e
puts "ZYppException caught"
- puts e.to_s
+ puts e
else
puts "Oh, no exception"
end
Modified: trunk/libzypp-bindings/swig/python/python.i
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp-bindings/swig/python/python.i?rev=7371&r1=7370&r2=7371&view=diff
==============================================================================
--- trunk/libzypp-bindings/swig/python/python.i (original)
+++ trunk/libzypp-bindings/swig/python/python.i Tue Sep 25 16:41:52 2007
@@ -22,3 +22,16 @@
};
%enddef
+
+%exception
+{
+ try {
+ $action
+ }
+ catch (const Exception& e) {
+ std::string tmp = e.historyAsString() + e.asUserString();
+ PyErr_SetString(PyExc_RuntimeError, const_cast