Add a frequency setting on the tracker

This commit is contained in:
Lucidiot 2018-10-20 19:05:45 +02:00
parent 6b2c2e5a24
commit 0f748c62e6
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
2 changed files with 9 additions and 3 deletions

View File

@ -22,7 +22,7 @@ This package provides a simple tracker script, `urbantz.tracker`, that can be
invoked like this:
``` 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

View File

@ -16,6 +16,12 @@ def main():
metavar='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()
delivery = options['delivery']
@ -29,9 +35,9 @@ def main():
print("{} {} meters".format(
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__':