Skip to content

Commit 0a06744

Browse files
committedSep 19, 2024
error on 404. Note that project is RETIRED
1 parent f8d8a9d commit 0a06744

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed
 

‎README.md

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
# Mozilla Location Services from Python
1+
# RETIRED: Mozilla Location Services from Python
22

33
[![ci](https://github.com/scivision/mozilla-location-wifi/actions/workflows/ci.yml/badge.svg)](https://github.com/scivision/mozilla-location-wifi/actions/workflows/ci.yml)
4-
[![PyPi Download stats](http://pepy.tech/badge/mozloc)](http://pepy.tech/project/mozloc)
4+
[![PyPI Download stats](http://pepy.tech/badge/mozloc)](http://pepy.tech/project/mozloc)
5+
6+
This project is RETIRED due to
7+
[discontinuation of Mozilla Location Services](https://discourse.mozilla.org/t/retiring-the-mozilla-location-service/128693).
8+
It worked so well, sorry to see it go!
9+
10+
This project can nonetheless be used as a reference for accessing WiFi information from Python.
11+
12+
A future direction might be to use
13+
[Google Geolocation API](https://developers.google.com/maps/documentation/geolocation/intro)
14+
15+
---
516

617
Uses command line access to WiFi information via
718
[Mozilla Location Services API](https://ichnaea.readthedocs.io/en/latest/api/geolocate.html?highlight=macaddress#wifi-access-point-fields)
819
from Python.
920
The command line programs used to access WiFi information include:
1021

1122
* Linux: [nmcli](https://developer.gnome.org/NetworkManager/stable/nmcli.html) NetworkManager
12-
* MacOS: [airport](https://ss64.com/osx/airport.html) built into MacOS
23+
* MacOS: [CoreLocation.CWWiFiClient](https://developer.apple.com/documentation/corewlan/cwwificlient) or for macOS < 14.4 [airport](https://ss64.com/osx/airport.html)
1324
* Windows: [netsh](https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh)
1425

15-
Note that a similar service with better accuracy is available from
16-
[Google](https://developers.google.com/maps/documentation/geolocation/intro).
17-
1826
## Install
1927

2028
Get latest release
@@ -47,16 +55,7 @@ python -m mozloc --dump
4755

4856
### macOS
4957

50-
Note: macOS 14.4+ no longer works as "airport" has been removed.
51-
If someone has time to implement, perhaps starting with example
52-
[CoreLocation](./macos_corelocation.py)
53-
code, we would welcome a PR.
54-
55-
On macOS, much more accurate results come by running as root by using sudo.
56-
This is because "airport" only emits BSSID if running with sudo.
57-
58-
Possible future implementation could use
59-
[CoreWLAN](https://developer.apple.com/documentation/corewlan/).
58+
macOS &ge; 14.4 uses CoreLocation.CWWiFiClient as "airport" was removed.
6059

6160
### Windows
6261

@@ -84,7 +83,7 @@ E.g.
8483

8584
## TODO
8685

87-
Would like to add Bluetooth beacons.
86+
Would like to add Bluetooth beacons. Need to use a new location service.
8887

8988
## Notes
9089

‎src/mozloc/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def log_wifi_loc(cadence_sec: float, mozilla_url: str, logfile: Path | None = No
4747
continue
4848

4949
loc = get_loc_mozilla(dat, mozilla_url)
50+
5051
if loc is None:
5152
logging.warning(f"Did not get location from {len(dat)} BSSIDs")
5253
sleep(cadence_sec)

‎src/mozloc/web.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ def get_loc_mozilla(dat: pandas.DataFrame, url: str):
1010
json_to = dat.to_json(orient="records")
1111

1212
json_to = '{ "wifiAccessPoints":' + json_to + "}"
13+
1314
try:
1415
req = requests.post(url, data=json_to)
16+
if req.status_code == 404:
17+
raise ConnectionError(f"Could not connect to {url} {req.status_code} {req.reason}")
1518
if req.status_code != 200:
16-
logging.error(req.text)
19+
logging.error(f"{req.status_code} {req.reason} {req.text}")
1720
return None
1821
except requests.exceptions.ConnectionError as e:
1922
logging.error(f"no network connection. {e}")

0 commit comments

Comments
 (0)
Please sign in to comment.