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:
|
||||
|
||||
``` 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
|
||||
|
|
|
@ -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__':
|
||||
|
|
Reference in New Issue