Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
efultz committed Jul 28, 2023
1 parent 1efc3c2 commit 0ff6135
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions gps_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def gps_fetch(cpool: SimpleConnectionPool, thalos_dir: Path):
SELECT t.file_dt FROM t
LEFT JOIN gpsdata ON t.file_dt = gpsdata.gps_datetime
WHERE gpsdata.gps_datetime IS NULL;""")
print(cur.query)
print(cur.description)
# print(cur.query)
# print(cur.description)
rows = cur.fetchall()
new_dts.extend(col for cols in rows for col in cols)

Expand All @@ -72,7 +72,7 @@ def gps_fetch(cpool: SimpleConnectionPool, thalos_dir: Path):
"INSERT INTO gpsdata (gps_datetime, lat, lon) VALUES (%s, %s, %s);",
insert_tuples
)
print(cur.query)
# print(cur.query)
conn.commit()
finally:
cpool.putconn(conn)
Expand Down
14 changes: 10 additions & 4 deletions video_fetch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from datetime import datetime,timezone
from datetime import datetime,timezone,timedelta
import click
import codecs
import os
Expand Down Expand Up @@ -51,18 +51,23 @@ def video_fetch(cpool: SimpleConnectionPool, thalos_dir: Path, output_dir: Path,
new_vids: list[Path] = []

discovered_matching_last_modified = 0
last_start_datetime = None

conn: psycopg2.connection = cpool.getconn()
try:
with conn.cursor() as cur:
for vid_file in depth_first_video_files(cameradir):
# if last_vid is None:
# last_vid = vid_file

start_datetime: datetime = datetime.strptime(
vid_file.name[0:len('20-07-2023-22-20')],
'%d-%m-%Y-%H-%M')
start_datetime = start_datetime.replace(tzinfo=timezone.utc)
if last_start_datetime is None:
last_start_datetime = start_datetime

if start_datetime + timedelta(days=2) < last_start_datetime :
# ok, we're too far back in time now. No reason to keep going back
# I'm done searching.
break

s = vid_file.stat()
last_modified: datetime = datetime.fromtimestamp(s.st_mtime, tz=timezone.utc)
Expand Down Expand Up @@ -96,6 +101,7 @@ def video_fetch(cpool: SimpleConnectionPool, thalos_dir: Path, output_dir: Path,
if len(new_vids) == 0:
# there are 0 videos for this camera. Skip this camera
continue
print("working on", len(new_vids), "new videos")

new_vids.reverse()

Expand Down

0 comments on commit 0ff6135

Please sign in to comment.