summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2015-01-14 16:15:54 -0800
committerKevron Rees <kevron.m.rees@intel.com>2015-01-14 16:21:28 -0800
commitebb94702832be544b58c70917601e8d5e04aa6bc (patch)
tree27c614caefdb71e4e5c5eb48802fe855448da22b
parentf5e7248e58978d65697397a3b39ba0be0a2949f6 (diff)
downloadautomotive-message-broker-ebb94702832be544b58c70917601e8d5e04aa6bc.tar.gz
[ambctl] - manual merge of fixes from 0.13.x
-rw-r--r--tools/ambctl.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/ambctl.py b/tools/ambctl.py
index 0a84d26c..1552c647 100644
--- a/tools/ambctl.py
+++ b/tools/ambctl.py
@@ -131,23 +131,29 @@ def processCommand(command, commandArgs, noMain=True):
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
- try:
- managerObject = bus.get_object("org.automotive.message.broker", "/");
- managerInterface = dbus.Interface(managerObject, "org.automotive.Manager")
- except:
- print "Error connecting to AMB. is AMB running?"
- return 1
+
+ def getManager(bus):
+ try:
+ managerObject = bus.get_object("org.automotive.message.broker", "/");
+ managerInterface = dbus.Interface(managerObject, "org.automotive.Manager")
+ return managerInterface
+ except:
+ print "Error connecting to AMB. is AMB running?"
+ return None
if command == "list" :
+ managerInterface = getManager(bus)
supportedList = managerInterface.List()
for objectName in supportedList:
print objectName
return 1
elif command == "get":
+ if len(commandArgs) == 0:
+ commandArgs = ['help']
if commandArgs[0] == "help":
print "ObjectName [ObjectName...]"
return 1
-
+ managerInterface = getManager(bus)
for objectName in commandArgs:
objects = managerInterface.FindObject(objectName)
print objectName
@@ -161,6 +167,7 @@ def processCommand(command, commandArgs, noMain=True):
if commandArgs[0] == "help":
print "ObjectName [ObjectName...]"
return 1
+ managerInterface = getManager(bus)
for objectName in commandArgs:
objects = managerInterface.FindObject(objectName)
for o in objects:
@@ -188,6 +195,7 @@ def processCommand(command, commandArgs, noMain=True):
zone = 0
if len(commandArgs) == 4:
zone = int(commandArgs[3])
+ managerInterface = getManager(bus)
object = managerInterface.FindObjectForZone(objectName, zone)
propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", object),"org.freedesktop.DBus.Properties")
property = propertiesInterface.Get("org.automotive."+objectName, propertyName)
@@ -220,6 +228,7 @@ def processCommand(command, commandArgs, noMain=True):
zone = 0
if len(commandArgs) >= 2:
zone = int(commandArgs[1])
+ managerInterface = getManager(bus)
object = managerInterface.FindObjectForZone(objectName, zone);
propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", object),"org.automotive."+objectName)
print json.dumps(propertiesInterface.GetHistory(start, end), indent=2)