gpio: Raise exception on GPIO lookup failure
This allows dbus calls to gpioInit to fail instead of only returning a
default value. This behavior allows the C-side GPIO lookup to error out
as expected.
Signed-off-by: Xo Wang <xow@google.com>
Change-Id: I13ad20de5d209716f26e46c12ca6941eb3dd5997
diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py
index 6f4bf81..e6bdd29 100644
--- a/pysystemmgr/system_manager.py
+++ b/pysystemmgr/system_manager.py
@@ -161,8 +161,10 @@
gpio_num = -1
r = ['', gpio_num, '']
if name not in System.GPIO_CONFIG:
- # TODO: Error handling
- print "ERROR: "+name+" not found in GPIO config table"
+ # TODO: Better error handling
+ msg = "ERROR: "+name+" not found in GPIO config table"
+ print msg
+ raise Exception(msg)
else:
gpio_num = -1
@@ -173,7 +175,9 @@
if 'gpio_pin' in System.GPIO_CONFIG[name]:
gpio_num = obmc.system.convertGpio(gpio['gpio_pin'])
else:
- print "ERROR: SystemManager - GPIO lookup failed for "+name
+ msg = "ERROR: SystemManager - GPIO lookup failed for "+name
+ print msg
+ raise Exception(msg)
if (gpio_num != -1):
r = [obmc.enums.GPIO_DEV, gpio_num, gpio['direction']]