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):
|
||||
bus = dbus.SessionBus()
|
||||
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
|
||||
self._on_geoclue_address_changed(0, {}, 0)
|
||||
self._on_geoclue_address_changed()
|
||||
return
|
||||
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
||||
'/org/freedesktop/Geoclue/Master')
|
||||
|
@ -61,7 +61,7 @@ class LocationListener:
|
|||
def _get_position(self):
|
||||
bus = dbus.SessionBus()
|
||||
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
|
||||
obj = bus.get_object('org.freedesktop.Geoclue.Master',
|
||||
'/org/freedesktop/Geoclue/Master')
|
||||
|
@ -89,23 +89,29 @@ class LocationListener:
|
|||
def shut_down(self):
|
||||
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
|
||||
for field in ['country', 'countrycode', 'locality', 'postalcode',
|
||||
'region', 'street']:
|
||||
self._data[field] = address.get(field, None)
|
||||
if timestamp:
|
||||
self._data['timestamp'] = timestamp
|
||||
if accuracy:
|
||||
# in PEP it's horizontal accuracy
|
||||
self._data['accuracy'] = accuracy[1]
|
||||
self._send_location()
|
||||
|
||||
def _on_geoclue_position_changed(self, fields, timestamp, lat, lon, alt,
|
||||
accuracy):
|
||||
def _on_geoclue_position_changed(self, fields=[], timestamp=None, lat=None,
|
||||
lon=None, alt=None, accuracy=None):
|
||||
# update data with info we just received
|
||||
_dict = {'lat': lat, 'lon': lon, 'alt': alt}
|
||||
for field in _dict:
|
||||
if _dict[field] is not None:
|
||||
self._data[field] = _dict[field]
|
||||
if timestamp:
|
||||
self._data['timestamp'] = timestamp
|
||||
if accuracy:
|
||||
# in PEP it's horizontal accuracy
|
||||
self._data['accuracy'] = accuracy[1]
|
||||
self._send_location()
|
||||
|
|
Loading…
Reference in New Issue