test: allow modem numbers in addition to object paths

If the command-line arg doesn't look like an object path,
treat it as the modem # and make the object path.
This commit is contained in:
Dan Williams
2011-08-09 12:00:51 +02:00
parent 33a97cdb13
commit f683391169
7 changed files with 30 additions and 8 deletions

View File

@@ -21,7 +21,10 @@ MM_DBUS_PATH='/org/freedesktop/ModemManager'
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
bus = dbus.SystemBus()
proxy = bus.get_object(MM_DBUS_SERVICE, sys.argv[1])
objpath = sys.argv[1]
if objpath[:1] != '/':
objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
modem.Enable (True)