blob: eece261b552d879cc277aa464600ef6ef47c392a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import traceback
import dbus
import sys
def execute_get(property_names):
bus = dbus.SessionBus()
try:
object = bus.get_object("org.freedesktop.ContextKit","/org/freedesktop/ContextKit/Manager")
iface = dbus.Interface(object,"org.freedesktop.ContextKit.Manager")
ret = iface.Get(property_names)
print "Returned:", ret
properties = ret[0]
undetermined = ret[1]
print "Properties and their values:"
for name in properties.keys():
print "Property:", name, ", value:", properties[name]
print "Undetermined properties:"
print undetermined
except dbus.DBusException:
print "Caught an exception"
traceback.print_exc()
if __name__ == "__main__":
# You can write the properties of intrest directly here
#execute_get(["Context.Device.Orientation.displayFacingUp", "Context.Environment.Location.latitude", "Context.Environment.Location.longitude", "Context.Environment.Location.altitude"])
# Or use the parameters from command line
print "Executing Get with the properties", sys.argv[1:]
execute_get(sys.argv[1:])
|