prevent traceback when geoclue not installed. Fixes #5495
This commit is contained in:
parent
408a2adffc
commit
6b7f36ebd1
|
@ -43,7 +43,7 @@ class LocationListener:
|
||||||
def _get_address(self):
|
def _get_address(self):
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
|
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
|
||||||
self._on_geoclue_address_changed(0, {}, 0)
|
self._on_geoclue_address_changed()
|
||||||
return
|
return
|
||||||
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
||||||
'/org/freedesktop/Geoclue/Master')
|
'/org/freedesktop/Geoclue/Master')
|
||||||
|
@ -61,7 +61,7 @@ class LocationListener:
|
||||||
def _get_position(self):
|
def _get_position(self):
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
|
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
|
||||||
self._on_geoclue_position_changed([], 0, None, None, 0)
|
self._on_geoclue_position_changed()
|
||||||
return
|
return
|
||||||
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
||||||
'/org/freedesktop/Geoclue/Master')
|
'/org/freedesktop/Geoclue/Master')
|
||||||
|
@ -89,25 +89,31 @@ class LocationListener:
|
||||||
def shut_down(self):
|
def shut_down(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _on_geoclue_address_changed(self, timestamp, address, accuracy):
|
def _on_geoclue_address_changed(self, timestamp=None, address={},
|
||||||
|
accuracy=None):
|
||||||
# update data with info we just received
|
# update data with info we just received
|
||||||
for field in ['country', 'countrycode', 'locality', 'postalcode',
|
for field in ['country', 'countrycode', 'locality', 'postalcode',
|
||||||
'region', 'street']:
|
'region', 'street']:
|
||||||
self._data[field] = address.get(field, None)
|
self._data[field] = address.get(field, None)
|
||||||
self._data['timestamp'] = timestamp
|
if timestamp:
|
||||||
# in PEP it's horizontal accuracy
|
self._data['timestamp'] = timestamp
|
||||||
self._data['accuracy'] = accuracy[1]
|
if accuracy:
|
||||||
|
# in PEP it's horizontal accuracy
|
||||||
|
self._data['accuracy'] = accuracy[1]
|
||||||
self._send_location()
|
self._send_location()
|
||||||
|
|
||||||
def _on_geoclue_position_changed(self, fields, timestamp, lat, lon, alt,
|
def _on_geoclue_position_changed(self, fields=[], timestamp=None, lat=None,
|
||||||
accuracy):
|
lon=None, alt=None, accuracy=None):
|
||||||
# update data with info we just received
|
# update data with info we just received
|
||||||
_dict = {'lat': lat, 'lon': lon, 'alt': alt}
|
_dict = {'lat': lat, 'lon': lon, 'alt': alt}
|
||||||
for field in _dict:
|
for field in _dict:
|
||||||
self._data[field] = _dict[field]
|
if _dict[field] is not None:
|
||||||
self._data['timestamp'] = timestamp
|
self._data[field] = _dict[field]
|
||||||
# in PEP it's horizontal accuracy
|
if timestamp:
|
||||||
self._data['accuracy'] = accuracy[1]
|
self._data['timestamp'] = timestamp
|
||||||
|
if accuracy:
|
||||||
|
# in PEP it's horizontal accuracy
|
||||||
|
self._data['accuracy'] = accuracy[1]
|
||||||
self._send_location()
|
self._send_location()
|
||||||
|
|
||||||
def _send_location(self):
|
def _send_location(self):
|
||||||
|
|
Loading…
Reference in New Issue