Skip to content

Commit 384d25a

Browse files
committed
use python -m instead of scripts
1 parent 31cd7dc commit 384d25a

File tree

7 files changed

+40
-55
lines changed

7 files changed

+40
-55
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pip install -e mozilla-location-wifi/
3232
## Usage
3333

3434
```sh
35-
MozLoc
35+
python -m mozloc
3636
```
3737

3838
Shows `time` `lat` `lng` `accuracy` `N BSSIDs heard`.
@@ -41,7 +41,7 @@ In urban areas, accuracy of less than 100 meters is possible.
4141
### dump raw signals
4242

4343
```sh
44-
mozloc_signal
44+
python -m mozloc.signal
4545
```
4646

4747
### Windows
@@ -54,7 +54,7 @@ You may need to disconnect from WiFi (leave WiFi enabled) to make your WiFi chip
5454
Display logged data in Google Earth or other KML viewer after converting from CSV to KML:
5555

5656
```sh
57-
python csv2kml.py in.log out.kml
57+
python -m mozloc.csv2kml in.log out.kml
5858
```
5959

6060
which uses

setup.cfg

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = mozloc
3-
version = 1.3.0
3+
version = 1.4.0
44
author = Michael Hirsch, Ph.D.
55
author_email = scivision@users.noreply.github.com
66
url = https://github.com/scivision/mozilla-location-wifi
@@ -45,9 +45,3 @@ lint =
4545
types-requests
4646
io =
4747
simplekml
48-
49-
[options.entry_points]
50-
console_scripts =
51-
MozLoc = mozloc.__main__:mozilla_location
52-
mozloc_signal = mozloc.__main__:wifi_signal
53-
mozloc_csv2kml = mozloc.__main__:csv2kml

src/mozloc/__main__.py

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,25 @@
77
Don't abuse the API or you'll get banned (excessive polling rate)
88
"""
99

10-
from .base import log_wifi_loc, process_file
11-
from .modules import get_signal
12-
13-
import pandas
14-
from argparse import ArgumentParser
15-
16-
17-
def wifi_signal():
18-
19-
wifi = get_signal()
20-
if isinstance(wifi, pandas.DataFrame):
21-
print(wifi)
22-
else:
23-
# list of dict
24-
for s in wifi:
25-
print(s)
10+
import argparse
2611

12+
from .base import log_wifi_loc, process_file
2713

28-
def mozilla_location():
29-
p = ArgumentParser()
30-
p.add_argument("logfile", help="logfile to append location to", nargs="?")
31-
p.add_argument(
32-
"-T", "--cadence", help="how often to update [sec]. Some laptops cannot go faster than 30 sec.", default=60, type=float
33-
)
34-
p.add_argument(
35-
"-url",
36-
help="Mozilla location services URL--don't use this default test key",
37-
default="https://location.services.mozilla.com/v1/geolocate?key=test",
38-
)
39-
p.add_argument("-i", "--infile", help="use raw text saved from command line")
40-
p = p.parse_args()
41-
42-
if p.infile:
43-
process_file(p.infile, mozilla_url=p.url)
44-
else:
45-
log_wifi_loc(cadence_sec=p.cadence, mozilla_url=p.url, logfile=p.logfile)
46-
47-
48-
def csv2kml():
49-
"""convert logged positions to KML"""
50-
from .utils import csv2kml
51-
52-
p = ArgumentParser()
53-
p.add_argument("logfn", help="csv logfile to read")
54-
p.add_argument("kmlfn", help="kml filename to write")
55-
p = p.parse_args()
5614

57-
csv2kml(p.logfn, p.kmlfn)
15+
p = argparse.ArgumentParser()
16+
p.add_argument("logfile", help="logfile to append location to", nargs="?")
17+
p.add_argument(
18+
"-T", "--cadence", help="how often to update [sec]. Some laptops cannot go faster than 30 sec.", default=60, type=float
19+
)
20+
p.add_argument(
21+
"-url",
22+
help="Mozilla location services URL--don't use this default test key",
23+
default="https://location.services.mozilla.com/v1/geolocate?key=test",
24+
)
25+
p.add_argument("-i", "--infile", help="use raw text saved from command line")
26+
p = p.parse_args()
27+
28+
if p.infile:
29+
process_file(p.infile, mozilla_url=p.url)
30+
else:
31+
log_wifi_loc(cadence_sec=p.cadence, mozilla_url=p.url, logfile=p.logfile)

src/mozloc/csv2kml/__init__.py

Whitespace-only changes.

src/mozloc/csv2kml/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""convert logged positions to KML"""
2+
3+
import argparse
4+
5+
from ..utils import csv2kml
6+
7+
p = argparse.ArgumentParser()
8+
p.add_argument("logfn", help="csv logfile to read")
9+
p.add_argument("kmlfn", help="kml filename to write")
10+
p = p.parse_args()
11+
12+
csv2kml(p.logfn, p.kmlfn)

src/mozloc/signal/__init__.py

Whitespace-only changes.

src/mozloc/signal/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pprint import pprint
2+
from ..modules import get_signal, parse_signal
3+
4+
5+
pprint(parse_signal(get_signal()))

0 commit comments

Comments
 (0)