forked from openbikesensor/portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_track.py
executable file
·46 lines (35 loc) · 1.2 KB
/
process_track.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
import logging
import asyncio
from obs.api.db import connect_db
from obs.api.app import app
from obs.api.process import process_tracks, process_tracks_loop
log = logging.getLogger(__name__)
async def main():
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(message)s")
parser = argparse.ArgumentParser(
description="processes a single track for use in the portal, "
"using the obs.face algorithms"
)
parser.add_argument(
"--loop-delay",
action="store",
type=int,
default=10,
help="delay between loops, if no track was found in the queue (polling)",
)
parser.add_argument(
"tracks",
metavar="ID_OR_SLUG",
nargs="*",
help="ID or slug of tracks to process, if not passed, the queue is processed in a loop",
)
args = parser.parse_args()
async with connect_db(app.config.POSTGRES_URL, app.config.POSTGRES_POOL_SIZE, app.config.POSTGRES_MAX_OVERFLOW):
if args.tracks:
await process_tracks(args.tracks)
else:
await process_tracks_loop(args.loop_delay)
if __name__ == "__main__":
asyncio.run(main())