diff options
author | Kevron Rees <kevron.m.rees@intel.com> | 2015-01-14 16:15:54 -0800 |
---|---|---|
committer | Kevron Rees <kevron.m.rees@intel.com> | 2015-01-14 16:21:28 -0800 |
commit | ebb94702832be544b58c70917601e8d5e04aa6bc (patch) | |
tree | 27c614caefdb71e4e5c5eb48802fe855448da22b | |
parent | f5e7248e58978d65697397a3b39ba0be0a2949f6 (diff) | |
download | automotive-message-broker-ebb94702832be544b58c70917601e8d5e04aa6bc.tar.gz |
[ambctl] - manual merge of fixes from 0.13.x
-rw-r--r-- | tools/ambctl.py | 23 |
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) |