Created
May 9, 2014 19:30
-
-
Save jonls/11337107e84442dd783d to your computer and use it in GitHub Desktop.
Geoclue2 test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import dbus | |
if __name__ == '__main__': | |
bus = dbus.SystemBus() | |
manager_obj = bus.get_object('org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager') | |
manager = dbus.Interface(manager_obj, 'org.freedesktop.GeoClue2.Manager') | |
client_path = manager.GetClient() | |
print 'Client at {}'.format(client_path) | |
client_obj = bus.get_object('org.freedesktop.GeoClue2', client_path) | |
client = dbus.Interface(client_obj, 'org.freedesktop.GeoClue2.Client') | |
client_props = dbus.Interface(client_obj, 'org.freedesktop.DBus.Properties') | |
client_props.Set('org.freedesktop.GeoClue2.Client', 'DistanceThreshold', dbus.UInt32(10000)) | |
client.Start() | |
print 'Client started...' | |
location_path = client_props.Get('org.freedesktop.GeoClue2.Client', 'Location') | |
location_obj = bus.get_object('org.freedesktop.GeoClue2', location_path) | |
location_props = dbus.Interface(location_obj, 'org.freedesktop.DBus.Properties') | |
print 'Location at {}'.format(location_path) | |
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Latitude') | |
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Longitude') | |
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Accuracy') | |
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Description') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment