Add a frequency setting on the tracker
This commit is contained in:
parent
6b2c2e5a24
commit
0f748c62e6
|
@ -22,7 +22,7 @@ This package provides a simple tracker script, `urbantz.tracker`, that can be
|
||||||
invoked like this:
|
invoked like this:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
python -m urbantz.tracker <ID> [-f|--freq <seconds>]
|
python -m urbantz.tracker <ID> [-f|--frequency <seconds>]
|
||||||
```
|
```
|
||||||
|
|
||||||
The script will perform a request every 10 seconds (by default) to the
|
The script will perform a request every 10 seconds (by default) to the
|
||||||
|
|
|
@ -16,6 +16,12 @@ def main():
|
||||||
metavar='ID',
|
metavar='ID',
|
||||||
help='A unique UrbanTZ delivery ID',
|
help='A unique UrbanTZ delivery ID',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-f', '--frequency',
|
||||||
|
type=int,
|
||||||
|
default=10,
|
||||||
|
help='Update frequency in seconds',
|
||||||
|
)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
delivery = options['delivery']
|
delivery = options['delivery']
|
||||||
|
|
||||||
|
@ -29,9 +35,9 @@ def main():
|
||||||
|
|
||||||
print("{} {} meters".format(
|
print("{} {} meters".format(
|
||||||
delivery.last_updated.isoformat(),
|
delivery.last_updated.isoformat(),
|
||||||
round(delivery.position.distance(delivery.destination), 1)
|
round(delivery.position.distance(delivery.destination), 1),
|
||||||
))
|
))
|
||||||
sleep(10)
|
sleep(options['frequency'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Reference in New Issue