[PATCH phosphor-objmgr] Make MapperNotFound a proper dbus exception

OpenBMC Patches openbmc-patches at stwcx.xyz
Tue Nov 10 10:50:25 AEDT 2015


From: Brad Bishop <bradleyb at us.ibm.com>

Set the name to org.openbmc.objectmapper.Error.NotFound
---
 OpenBMCMapper.py |  5 +----
 phosphor-mapper  | 10 ++++++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/OpenBMCMapper.py b/OpenBMCMapper.py
index 1233c70..2ed65f7 100644
--- a/OpenBMCMapper.py
+++ b/OpenBMCMapper.py
@@ -23,10 +23,7 @@ MAPPER_NAME = 'org.openbmc.objectmapper'
 MAPPER_IFACE = MAPPER_NAME + '.ObjectMapper'
 MAPPER_PATH = '/org/openbmc/objectmapper/objectmapper'
 ENUMERATE_IFACE = 'org.openbmc.Object.Enumerate'
-
-class MapperNotFoundException(Exception):
-	def __init__(self, msg):
-		super(MapperNotFoundException, self).__init__(msg)
+MAPPER_NOT_FOUND = 'org.openbmc.objectmapper.Error.NotFound'
 
 class Path:
 	def __init__(self, path):
diff --git a/phosphor-mapper b/phosphor-mapper
index 36bf09b..011dc56 100644
--- a/phosphor-mapper
+++ b/phosphor-mapper
@@ -16,14 +16,20 @@
 # implied. See the License for the specific language governing
 # permissions and limitations under the License.
 
-import sys
 import dbus
 import dbus.service
+import dbus.exceptions
 import dbus.mainloop.glib
 import gobject
-from OpenBMCMapper import Path, IntrospectionParser, PathTree
+from OpenBMCMapper import IntrospectionParser, PathTree
 import OpenBMCMapper
 
+class MapperNotFoundException(dbus.exceptions.DBusException):
+	_dbus_error_name = OpenBMCMapper.MAPPER_NOT_FOUND
+	def __init__(self, path):
+		super(MapperNotFoundException, self).__init__(
+				"path or object not found: %s" %(path))
+
 class ObjectMapper(dbus.service.Object):
 	def __init__(self, bus, path,
 			name_match = OpenBMCMapper.org_dot_openbmc_match,
-- 
2.6.3




More information about the openbmc mailing list