| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | import dbus |
|---|
| 4 | |
|---|
| 5 | bus = dbus.SystemBus() |
|---|
| 6 | usage = dbus.Interface(bus.get_object("org.freesmartphone.ousaged", |
|---|
| 7 | "/org/freesmartphone/Usage"), "org.freesmartphone.Usage") |
|---|
| 8 | dbusi = dbus.Interface(bus.get_object("org.freedesktop.DBus", |
|---|
| 9 | "/"), "org.freedesktop.DBus") |
|---|
| 10 | |
|---|
| 11 | print "%-16sPolicy\tState\tUsers" % "Name" |
|---|
| 12 | for i in usage.ListResources(): |
|---|
| 13 | print "%-16s%s\t%s\t" % ( i, usage.GetResourcePolicy(i), usage.GetResourceState(i) ), |
|---|
| 14 | for s in usage.GetResourceUsers(i): |
|---|
| 15 | pid = dbusi.GetConnectionUnixProcessID(s) |
|---|
| 16 | cmdline = open( "/proc/%s/cmdline" % pid, 'r' ).read().replace("\0", " ") |
|---|
| 17 | print "%s %s" % ( pid, cmdline ), |
|---|
| 18 | print |
|---|
| 19 | |
|---|