Hello community, here is the log from the commit of package cmpi-bindings for openSUSE:Factory checked in at 2014-06-25 21:20:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cmpi-bindings (Old) and /work/SRC/openSUSE:Factory/.cmpi-bindings.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cmpi-bindings" Changes: -------- --- /work/SRC/openSUSE:Factory/cmpi-bindings/cmpi-bindings.changes 2014-03-18 13:41:46.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.cmpi-bindings.new/cmpi-bindings.changes 2014-06-25 21:20:13.000000000 +0200 @@ -1,0 +2,9 @@ +Wed Jun 25 10:35:41 UTC 2014 - [email protected] + +- Update to 1.0.0 + - Transport CMPIStatus information from Ruby to CMPI API. + - Add Ruby classes representing CMPI error codes. + - Capture call results and raise proper exceptions. + - Fix Fedora 20 build + +------------------------------------------------------------------- Old: ---- cmpi-bindings-0.9.9.tar.bz2 New: ---- cmpi-bindings-1.0.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cmpi-bindings.spec ++++++ --- /var/tmp/diff_new_pack.WX79I3/_old 2014-06-25 21:20:14.000000000 +0200 +++ /var/tmp/diff_new_pack.WX79I3/_new 2014-06-25 21:20:14.000000000 +0200 @@ -20,7 +20,7 @@ Url: http://github.com/kkaempf/cmpi-bindings Name: cmpi-bindings -Version: 0.9.9 +Version: 1.0.0 Release: 0 Summary: Adapter to write and run CMPI-type CIM providers License: BSD-3-Clause and CPL-1.0 ++++++ cmpi-bindings-0.9.9.tar.bz2 -> cmpi-bindings-1.0.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/VERSION.cmake new/cmpi-bindings-1.0.0/VERSION.cmake --- old/cmpi-bindings-0.9.9/VERSION.cmake 2014-02-05 11:29:42.000000000 +0100 +++ new/cmpi-bindings-1.0.0/VERSION.cmake 2014-06-25 12:37:58.000000000 +0200 @@ -1,3 +1,3 @@ -SET(VERSION_MAJOR "0") -SET(VERSION_MINOR "9") -SET(VERSION_PATCH "9") +SET(VERSION_MAJOR "1") +SET(VERSION_MINOR "0") +SET(VERSION_PATCH "0") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/package/cmpi-bindings.changes new/cmpi-bindings-1.0.0/package/cmpi-bindings.changes --- old/cmpi-bindings-0.9.9/package/cmpi-bindings.changes 2014-02-05 11:59:52.000000000 +0100 +++ new/cmpi-bindings-1.0.0/package/cmpi-bindings.changes 2014-06-25 12:38:45.000000000 +0200 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Wed Jun 25 10:35:41 UTC 2014 - [email protected] + +- Update to 1.0.0 + - Transport CMPIStatus information from Ruby to CMPI API. + - Add Ruby classes representing CMPI error codes. + - Capture call results and raise proper exceptions. + - Fix Fedora 20 build + +------------------------------------------------------------------- Wed Feb 5 10:59:36 UTC 2014 - [email protected] - Update to 0.9.9 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/package/cmpi-bindings.spec.in new/cmpi-bindings-1.0.0/package/cmpi-bindings.spec.in --- old/cmpi-bindings-0.9.9/package/cmpi-bindings.spec.in 2013-12-12 14:14:33.000000000 +0100 +++ new/cmpi-bindings-1.0.0/package/cmpi-bindings.spec.in 2014-03-11 09:34:51.000000000 +0100 @@ -59,7 +59,7 @@ BuildRequires: ruby-rdoc %endif -%if 0%{?fedora} == 19 +%if 0%{?fedora} > 18 BuildRequires: rubypick %endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/src/target_ruby.c new/cmpi-bindings-1.0.0/src/target_ruby.c --- old/cmpi-bindings-0.9.9/src/target_ruby.c 2013-10-09 13:30:04.000000000 +0200 +++ new/cmpi-bindings-1.0.0/src/target_ruby.c 2014-06-25 12:34:06.000000000 +0200 @@ -166,9 +166,9 @@ #define TB_ERROR(str) {tbstr = str; goto cleanup;} static CMPIString * -get_exc_trace(const CMPIBroker* broker) +get_exc_trace(const CMPIBroker* broker, int *rc_ptr) { - VALUE exception = rb_gv_get("$!"); /* get last exception */ + VALUE exception = rb_errinfo(); /* get last exception */ VALUE reason = rb_funcall(exception, rb_intern("to_s"), 0 ); VALUE trace = rb_gv_get("$@"); /* get last exception trace */ VALUE backtrace; @@ -179,6 +179,12 @@ _SBLIM_TRACE(1,("<%d> Ruby: get_exc_trace: no exception", getpid())); return NULL; } + if (rc_ptr) { + VALUE rc = rb_iv_get(exception, "@rc"); + if (FIXNUM_P(rc)) { + *rc_ptr = FIX2INT(rc); + } + } if (NIL_P(trace)) { _SBLIM_TRACE(1,("<%d> Ruby: get_exc_trace: no trace ($@ is nil)", getpid())); return NULL; @@ -320,9 +326,10 @@ fail: if (error) { - CMPIString *trace = get_exc_trace(hdl->broker); + int rc; + CMPIString *trace = get_exc_trace(hdl->broker, &rc); if (st != NULL) { - st->rc = CMPI_RC_ERR_INVALID_CLASS; + st->rc = rc; st->msg = trace; } } @@ -414,9 +421,11 @@ result = rb_protect(call_mi, (VALUE)args, &i); if (i) { /* exception ? */ - CMPIString *trace = get_exc_trace(hdl->broker); + int rc; + CMPIString *trace = get_exc_trace(hdl->broker, &rc); char *trace_s; char* str; + if (trace) { trace_s = CMGetCharPtr(trace); } @@ -426,8 +435,8 @@ str = fmtstr("Ruby: calling '%s' failed: %s", opname, trace_s); if (trace) trace->ft->release(trace); - _SBLIM_TRACE(1,("%s", str)); - st->rc = CMPI_RC_ERR_FAILED; + _SBLIM_TRACE(1,("TargetCall %s failed, trace: %s", opname, str)); + st->rc = rc; st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); goto done; @@ -562,7 +571,8 @@ result = rb_protect(call_ttv, (VALUE)args, &error); if (error) { - CMPIString *trace = get_exc_trace(hdl->broker); + int rc; + CMPIString *trace = get_exc_trace(hdl->broker, &rc); char *trace_s; char* str; if (trace) { @@ -575,7 +585,7 @@ if (trace) trace->ft->release(trace); _SBLIM_TRACE(1,("%s", str)); - status->rc = CMPI_RC_ERR_FAILED; + status->rc = rc; status->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/swig/cmpi.i new/cmpi-bindings-1.0.0/swig/cmpi.i --- old/cmpi-bindings-0.9.9/swig/cmpi.i 2013-04-18 15:23:52.000000000 +0200 +++ new/cmpi-bindings-1.0.0/swig/cmpi.i 2014-06-25 11:07:04.000000000 +0200 @@ -777,26 +777,54 @@ static void _raise_ex(const CMPIStatus* st) { + char* msg = NULL; + if (st->msg) { + msg = strdup(CMGetCharsPtr(st->msg, NULL)); + } #ifdef SWIGPYTHON PyObject* obj; CMPIException* ex; ex = (CMPIException*)malloc(sizeof(CMPIException)); ex->error_code = st->rc; - - if (st->msg) { - const char* chars = CMGetCharsPtr(st->msg, NULL); - ex->description = strdup(chars); - } - else - ex->description = NULL; + ex->description = msg; SWIG_PYTHON_THREAD_BEGIN_BLOCK; obj = SWIG_NewPointerObj(ex, SWIGTYPE_p__CMPIException, SWIG_POINTER_OWN); PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p__CMPIException), obj); SWIG_PYTHON_THREAD_END_BLOCK; _set_raised(); -#endif /* SWIGPYTHON */ + if (msg) + free(msg); +#endif + +#ifdef SWIGRUBY + VALUE exception_klass = rb_funcall(mCmpi, rb_intern("rc_to_exception"), 1, Target_Int(st->rc)); + VALUE exception; + if (NIL_P(exception_klass)) { + /* no error */ + return; + } + exception = rb_funcall(exception_klass, rb_intern("new"), 2, Target_Int(st->rc), Target_String(msg ? msg : "")); + if (msg) + free(msg); + rb_exc_raise(exception); +#endif + +#if !defined(SWIGPYTHON) && !defined(SWIGRUBY) + /* default implementation */ + if (msg == NULL) { + msg = (char *)malloc(16); + snprintf(msg, 15, "Cmpi rc %d", st->rc); + } + SWIG_exception(SWIG_RuntimeError, msg); + if (msg) + free(msg); +#endif +#if !defined (SWIGRUBY) +fail: +#endif + return; } /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/swig/cmpi_types.i new/cmpi-bindings-1.0.0/swig/cmpi_types.i --- old/cmpi-bindings-0.9.9/swig/cmpi_types.i 2014-02-05 14:11:00.000000000 +0100 +++ new/cmpi-bindings-1.0.0/swig/cmpi_types.i 2014-06-25 12:28:57.000000000 +0200 @@ -584,7 +584,14 @@ SWIG_exception(SWIG_ValueError, "bad expected_type"); } name = target_charptr(property); - actual_type = target_to_value(data, &value, type); + if (NIL_P(data)) { + actual_type = type; /* prevent type error */ + value.chars = NULL; + } + else { + actual_type = target_to_value(data, &value, type); + } +/* fprintf(stderr, "CMPIObjectPath.%s <expected %04x, actual %04x>\n",name, type, actual_type); */ status = CMAddKey($self, name, &value, actual_type); RAISE_IF(status); return status; @@ -624,8 +631,10 @@ name = target_charptr(property); #endif result = CMGetKey($self, name, &st); - RAISE_IF(st); - + /* key not found is ok, will return NULL */ + if (st.rc != CMPI_RC_ERR_NOT_FOUND) { + RAISE_IF(st); + } #if defined(SWIGRUBY) return data_value(&result); #else @@ -917,7 +926,14 @@ SWIG_exception(SWIG_ValueError, "bad expected_type"); } name = target_charptr(property); - actual_type = target_to_value(data, &value, type); + if (NIL_P(data)) { + actual_type = type; /* prevent type error */ + value.chars = NULL; + } + else { + actual_type = target_to_value(data, &value, type); + } +/* fprintf(stderr, "CMPIInstance.%s <expected %04x, actual %04x>\n",name, type, actual_type); */ status = CMSetProperty($self, name, &value, actual_type); RAISE_IF(status); return status; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/swig/ruby/cmpi-bindings.gemspec.in new/cmpi-bindings-1.0.0/swig/ruby/cmpi-bindings.gemspec.in --- old/cmpi-bindings-0.9.9/swig/ruby/cmpi-bindings.gemspec.in 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-1.0.0/swig/ruby/cmpi-bindings.gemspec.in 2014-06-24 09:49:55.000000000 +0200 @@ -9,11 +9,12 @@ s.homepage = "http://www.github.com/kkaempf/cmpi-bindings" s.summary = "Write CIM providers in Ruby" s.description = "The cmpi-bindings gem provides a Ruby API to write CIM providers" + s.licenses = ['BSD-3-Clause', 'CPL-1.0'] s.required_rubygems_version = ">= 1.3.6" - s.add_development_dependency("rake-compiler", [">= 0"]) - s.add_development_dependency("mocha", [">= 0.9"]) - s.add_development_dependency("yard", [">= 0.5"]) + s.add_development_dependency("rake-compiler", ["~> 0"]) + s.add_development_dependency("mocha", ["~> 0.9"]) + s.add_development_dependency("yard", ["~> 0.5"]) s.extensions << "ext/cmpi-bindings/extconf.rb" s.files = Dir.glob("lib/*.rb") + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.9/swig/ruby/cmpi.rb new/cmpi-bindings-1.0.0/swig/ruby/cmpi.rb --- old/cmpi-bindings-0.9.9/swig/ruby/cmpi.rb 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-1.0.0/swig/ruby/cmpi.rb 2014-06-25 11:07:51.000000000 +0200 @@ -192,6 +192,57 @@ CMPI_ARRAY | self.embedded_instance end + class RCErr < ::StandardError + def initialize rc,msg + super msg + @rc = rc + end + end + class RCErrFailed < RCErr; end + class RCErrAccessDenied < RCErr; end + class RCErrInvalidNamespace < RCErr; end + class RCErrInvalidParameter < RCErr; end + class RCErrInvalidClass < RCErr; end + class RCErrNotFound < RCErr; end + class RCErrNotSupported < RCErr; end + class RCErrClassHasChildren < RCErr; end + class RCErrClassHasInstances < RCErr; end + class RCErrInvalidSuperclass < RCErr; end + class RCErrAlreadyExists < RCErr; end + class RCErrNoSuchProperty < RCErr; end + class RCErrTypeMismatch < RCErr; end + class RCErrQueryLanguageNotSupported < RCErr; end + class RCErrInvalidQuery < RCErr; end + class RCErrMethodNotAvailable < RCErr; end + class RCErrMethodNotFound < RCErr; end + class RCErrSystem < RCErr; end + # convert CMPIStatus rc code to Ruby exception + def self.rc_to_exception rc + return nil if rc == 0 + klass = + [nil, # 0 /** Success */ CMPI_RC_OK = 0, + RCErrFailed, # 1 /** Generic failure */ CMPI_RC_ERR_FAILED = 1, + RCErrAccessDenied, # 2 /** Specified user does not have access to perform the requested action */ CMPI_RC_ERR_ACCESS_DENIED = 2, + RCErrInvalidNamespace, # 3 /** invalid namespace specified */ CMPI_RC_ERR_INVALID_NAMESPACE = 3, + RCErrInvalidParameter, # 4 /** invalid parameter specified */ CMPI_RC_ERR_INVALID_PARAMETER = 4, + RCErrInvalidClass, # 5 /** Invalid class specified */ CMPI_RC_ERR_INVALID_CLASS = 5, + RCErrNotFound, # 6 /** Item was not found */ CMPI_RC_ERR_NOT_FOUND = 6, + RCErrNotSupported, # 7 /** Operation not supported */ CMPI_RC_ERR_NOT_SUPPORTED = 7, + RCErrClassHasChildren, # 8 /** Object has child objects */ CMPI_RC_ERR_CLASS_HAS_CHILDREN = 8, + RCErrClassHasInstances, # 9 /** Object has instances */ CMPI_RC_ERR_CLASS_HAS_INSTANCES = 9, + RCErrInvalidSuperclass, # 10 /** Invalid super class specified */ CMPI_RC_ERR_INVALID_SUPERCLASS = 10, + RCErrAlreadyExists, # 11 /** specified object already exists */ CMPI_RC_ERR_ALREADY_EXISTS = 11, + RCErrNoSuchProperty, # 12 /** Property does not exist */ CMPI_RC_ERR_NO_SUCH_PROPERTY = 12, + RCErrTypeMismatch, # 13 /** This is a type mismatch */ CMPI_RC_ERR_TYPE_MISMATCH = 13, + RCErrQueryLanguageNotSupported, # 14 /** Query language not supported */ CMPI_RC_ERR_QUERY_LANGUAGE_NOT_SUPPORTED = 14, + RCErrInvalidQuery, # 15 /** Invalid query */ CMPI_RC_ERR_INVALID_QUERY = 15, + RCErrMethodNotAvailable,# 16 /** Method is not available */ CMPI_RC_ERR_METHOD_NOT_AVAILABLE = 16, + RCErrMethodNotFound # 17 /** could not find the specified method */ CMPI_RC_ERR_METHOD_NOT_FOUND = 17, + ][rc] + return RuntimeError unless klass + klass + end + # # Convert CIM DateTime string representation (see DSP0004, 2.2.1) # to Ruby Time (timestamp) or Float (interval, as seconds with fraction) @@ -217,7 +268,7 @@ off += str[15,6].to_i / 1000 return off else - raise "Invalid CIM DateTime '#{str}'" + raise RCErrInvalidParameter.new(CMPI_RC_ERR_INVALID_PARAMETER, "Invalid CIM DateTime '#{str}'") end end @@ -314,16 +365,21 @@ end end def to_s + # objectpath only covers the key properties path = objectpath keys = [] path.each { |val,name| keys << name } + # now iterate over the instance properties, filter + # out the key properties from the objectpath + # and collect the non-key properties s = "" self.each do |value,name| - next unless value - next if keys.include? name - s << ", " unless s.empty? - s << "\"#{name}\"=>#{value.inspect}" + next unless value + next if keys.include? name + s << ", " unless s.empty? + s << "\"#{name}\"=#{value.inspect}" end + # path has the key properties, s has the non-key properties "#{path} #{s}" end # @@ -339,12 +395,12 @@ begin @typemap = Cmpi.const_get(self.objectpath.classname).typemap rescue NoMethodError - raise "Cmpi::#{self.objectpath.classname}.typemap not defined" + raise RCErrInvalidClass.new(CMPI_RC_ERR_INVALID_CLASS, "Cmpi::#{self.objectpath.classname}.typemap not defined") end end t = @typemap[n] - raise "Property '#{n}' of Cmpi::#{self.objectpath.classname}.typemap not defined" unless t -# STDERR.printf "Instance.%s = %s[%s]:%04x\n" % [n, v, v.class, t] + raise RCErrNotFound.new(CMPI_RC_ERR_NOT_FOUND, "Property '#{n}' of Cmpi::#{self.objectpath.classname}.typemap not defined") unless t + STDERR.printf "Instance.%s = %s[%s]:%04x\n" % [n, v, v.class, t] self[n,v] = t else # STDERR.puts "CMPIInstance.#{name} -> #{self[s].inspect}" @@ -371,11 +427,11 @@ begin @typemap = Cmpi.const_get(self.classname).typemap rescue NameError - raise "Cmpi::#{self.classname}.typemap not defined" + raise RCErrInvalidClass.new(CMPI_RC_ERR_INVALID_CLASS, "Cmpi::#{self.classname}.typemap not defined") end end t = @typemap[n] - raise "Property '#{n}' of Cmpi::#{self.classname}.typemap not defined" unless t + raise RCErrNotFound.new(CMPI_RC_ERR_NOT_FOUND, "Property '#{n}' of Cmpi::#{self.classname}.typemap not defined") unless t # STDERR.printf "ObjectPath.%s = %s[%s]:%04x\n" % [n, v, v.class, t] self[n,v] = t else -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
