[yast-commit] r46766 - in /trunk/pkg-bindings: VERSION package/yast2-pkg-bindings.changes src/Resolvable_Properties.cc
Author: coolo Date: Wed Apr 16 18:21:41 2008 New Revision: 46766 URL: http://svn.opensuse.org/viewcvs/yast?rev=46766&view=rev Log: catching errors - programming defensive (bnc#380283) Modified: trunk/pkg-bindings/VERSION trunk/pkg-bindings/package/yast2-pkg-bindings.changes trunk/pkg-bindings/src/Resolvable_Properties.cc Modified: trunk/pkg-bindings/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/VERSION?rev=46766&r1=46765&r2=46766&view=diff ============================================================================== --- trunk/pkg-bindings/VERSION (original) +++ trunk/pkg-bindings/VERSION Wed Apr 16 18:21:41 2008 @@ -1 +1 @@ -2.16.27 +2.16.28 Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=46766&r1=46765&r2=46766&view=diff ============================================================================== --- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Apr 16 18:21:41 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Apr 16 18:21:09 CEST 2008 - coolo@suse.de + +- catching errors - programming defensive (bnc#380283) +- 2.16.28 + +------------------------------------------------------------------- Wed Apr 16 15:07:02 CEST 2008 - lslezak@suse.cz - searchPackage - use isSystem() property instead of searching Modified: trunk/pkg-bindings/src/Resolvable_Properties.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Resolvable_Properties.cc?rev=46766&r1=46765&r2=46766&view=diff ============================================================================== --- trunk/pkg-bindings/src/Resolvable_Properties.cc (original) +++ trunk/pkg-bindings/src/Resolvable_Properties.cc Wed Apr 16 18:21:41 2008 @@ -50,7 +50,7 @@ @short Return properties of resolvable @description return list of resolvables of selected kind with required name - + @param name name of the resolvable, if empty returns all resolvables of the kind @param kind_r kind of resolvable, can be `product, `patch, `package, `pattern or `language @param version version of the resolvable, if empty all versions are returned @@ -59,7 +59,7 @@ status is `installed, `removed, `selected or `available, source is source ID or -1 if the resolvable is installed in the target if status is `available and locked is true then the object is set to taboo, if status is `installed and locked is true then the object locked - if status is `selected or `removed there is extra key "transact_by" : symbol, where symbol is `user (the highest level), + if status is `selected or `removed there is extra key "transact_by" : symbol, where symbol is `user (the highest level), `app_high (selected by Yast), `app_low and `solver (the lowest level) */ @@ -94,7 +94,7 @@ case zypp::ResStatus::SOLVER : ret = "solver"; break; } - return ret; + return ret; } YCPValue @@ -131,7 +131,7 @@ try { const zypp::LocaleSet &avlocales( zypp::ResPool::instance().getAvailableLocales() ); - + for_( it, avlocales.begin(), avlocales.end() ) { zypp::sat::LocaleSupport myLocale( *it ); @@ -162,7 +162,7 @@ } try - { + { for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(kind); it != zypp_ptr()->pool().byKindEnd(kind); ++it) @@ -230,27 +230,37 @@ info->add(YCPString("medium_nr"), YCPInteger((*it)->mediaNr())); info->add(YCPString("vendor"), YCPString((*it)->vendor())); - + // package specific info if( req_kind == "package" ) { zypp::Package::constPtr pkg = boost::dynamic_pointer_cast<const zypp::Package>(it->resolvable()); - - std::string tmp = pkg->location().filename().asString(); - if (!tmp.empty()) + if ( pkg ) { - info->add(YCPString("path"), YCPString(tmp)); - } - - tmp = pkg->location().filename().basename(); - if (!tmp.empty()) - { - info->add(YCPString("location"), YCPString(tmp)); - } + std::string tmp = pkg->location().filename().asString(); + if (!tmp.empty()) + { + info->add(YCPString("path"), YCPString(tmp)); + } + + tmp = pkg->location().filename().basename(); + if (!tmp.empty()) + { + info->add(YCPString("location"), YCPString(tmp)); + } + } else + { + y2error("package %s is not a package", (*it)->name() ); + } } // product specific info else if( req_kind == "product" ) { zypp::Product::constPtr product = boost::dynamic_pointer_cast<const zypp::Product>(it->resolvable()); + if ( !product ) + { + y2error("product %s is not a product", (*it)->name() ); + continue; + } #warning "Product::category is deprecated, remove from YCP code and this map" info->add(YCPString("category"), YCPString(product->type())); info->add(YCPString("type"), YCPString(product->type())); @@ -327,7 +337,7 @@ else if ( req_kind == "patch" ) { zypp::Patch::constPtr patch_ptr = boost::dynamic_pointer_cast<const zypp::Patch>(it->resolvable()); - + info->add(YCPString("interactive"), YCPBoolean(patch_ptr->interactive())); info->add(YCPString("reboot_needed"), YCPBoolean(patch_ptr->reboot_needed())); info->add(YCPString("affects_pkg_manager"), YCPBoolean(patch_ptr->affects_pkg_manager())); @@ -363,7 +373,7 @@ ycpdep->add (YCPString ("dep_kind"), YCPString (*kind_it)); ycpdeps->add (ycpdep); } - + } catch (...) {} @@ -411,7 +421,7 @@ } else if ( req_kind == "any" ) { try - { + { for (zypp::ResPool::const_iterator it = zypp_ptr()->pool().begin(); it != zypp_ptr()->pool().end(); ++it) @@ -432,7 +442,7 @@ return YCPNull(); } - return YCPBoolean(false); + return YCPBoolean(false); } else { @@ -442,7 +452,7 @@ try - { + { for (zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(kind); it != zypp_ptr()->pool().byKindEnd(kind); ++it) @@ -463,6 +473,6 @@ return YCPNull(); } - return YCPBoolean(false); + return YCPBoolean(false); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
coolo@svn.opensuse.org