1 #!/usr/bin/python 2 3 import dbus, flimflam, sys 4 5 if (len(sys.argv) < 2): 6 print "Usage: %s <device | interface>" % (sys.argv[0]) 7 sys.exit(1) 8 9 (_, name) = sys.argv 10 11 flim = flimflam.FlimFlam(dbus.SystemBus()) 12 13 device = flim.FindElementByNameSubstring('Device', name) 14 if device is None: 15 device = flim.FindElementByPropertySubstring('Device', 'Interface', name) 16 17 print "Disabling device %s" % (device.object_path) 18 19 # Shill uses the Disable method, flimflam uses a SetProperty call 20 try: 21 device.Disable() 22 except dbus.DBusException, error: 23 device.SetProperty("Powered", dbus.Boolean(0)) 24