Guest User

GeoClue2 Locator

a guest
Oct 20th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import dbus
  4.  
  5. from dbus.mainloop.glib import DBusGMainLoop
  6.  
  7.  
  8. def location_updated(old_path, new_path):
  9.     print "Old location path = " + str(old_path)
  10.     print "New location path = " + str(new_path)
  11.  
  12. def main():
  13.     dbus_loop = DBusGMainLoop(set_as_default = True)
  14.  
  15.     system_bus = dbus.SystemBus(mainloop = dbus_loop)
  16.  
  17.     manager_object = system_bus.get_object('org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager')
  18.     manager = dbus.Interface(manager_object, 'org.freedesktop.GeoClue2.Manager')
  19.  
  20.     client_path = manager.GetClient()
  21.     client_object = system_bus.get_object('org.freedesktop.GeoClue2', client_path)
  22.     client = dbus.Interface(client_object, 'org.freedesktop.GeoClue2.Client')
  23.     client.connect_to_signal('LocationUpdated', location_updated)
  24.     client.Start()
  25.  
  26.     properties = dbus.Interface(client_object, 'org.freedesktop.DBus.Properties')
  27.     location_path = properties.Get('org.freedesktop.GeoClue2.Client', 'Location')
  28.  
  29.     print "Path to Location Object = " + str(location_path) # Always prints '/' irrespective of client.Start()
  30.  
  31.     client.Stop()
  32.  
  33. main()
Advertisement
Add Comment
Please, Sign In to add comment