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