Iterating through users, then looping through cameras, and finally through downloads
parent
a0c2f2a712
commit
7cd2a5c80d
|
@ -101,62 +101,67 @@ if __name__ == '__main__':
|
||||||
logging.info(f"EagleEyev3 version: {een.__version__}")
|
logging.info(f"EagleEyev3 version: {een.__version__}")
|
||||||
|
|
||||||
|
|
||||||
|
results = cur.execute('select email from user')
|
||||||
|
|
||||||
if een:
|
list_of_users = [r[0] for r in results]
|
||||||
if een.refresh_token == None or een.refresh_token == '':
|
|
||||||
# if you get out of sync, pull the refresh_token from the db to get the loop started
|
for user_email in list_of_users:
|
||||||
result = cur.execute("select user.refresh_token from user where user.email = ?;", ("mcotton@mcottondesign.com",))
|
|
||||||
|
if een:
|
||||||
|
|
||||||
|
result = cur.execute("select user.refresh_token from user where user.email = ?;", (user_email,))
|
||||||
|
|
||||||
for row in result:
|
for row in result:
|
||||||
een.refresh_token = row[0]
|
een.refresh_token = row[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# een object and refresh_token appear to be good
|
logging.error('een object is None')
|
||||||
pass
|
|
||||||
else:
|
|
||||||
logging.error('een object is None')
|
|
||||||
|
|
||||||
|
|
||||||
een.login_tokens(code=None, cascade=True, refresh_token=een.refresh_token)
|
een.login_tokens(code=None, cascade=True, refresh_token=een.refresh_token)
|
||||||
|
|
||||||
result = cur.execute("select user.refresh_token, user.id from user where user.email = ?;", (een.current_user['email'],))
|
if een and een.current_user and 'email' in een.current_user:
|
||||||
|
|
||||||
for row in result:
|
result = cur.execute("select user.refresh_token, user.id from user where user.email = ?;", (een.current_user['email'],))
|
||||||
print(f"found user {een.current_user['email']}, updating refresh_token")
|
|
||||||
print(row)
|
for row in result:
|
||||||
print(een.refresh_token)
|
print(f"found user {een.current_user['email']}, updating refresh_token")
|
||||||
print(f"update user set refresh_token = {een.refresh_token} where id == {row[1]};")
|
print(row)
|
||||||
cur.execute("update user set refresh_token = ? where id == ?;", (een.refresh_token, row[1]))
|
print(een.refresh_token)
|
||||||
con.commit()
|
print(f"update user set refresh_token = {een.refresh_token} where id == {row[1]};")
|
||||||
|
cur.execute("update user set refresh_token = ? where id == ?;", (een.refresh_token, row[1]))
|
||||||
|
con.commit()
|
||||||
|
|
||||||
|
|
||||||
een.get_list_of_cameras()
|
een.get_list_of_cameras()
|
||||||
|
|
||||||
|
|
||||||
# iterate through all the cameras this user has access to
|
# iterate through all the cameras this user has access to
|
||||||
for current_camera in een.cameras:
|
for current_camera in een.cameras:
|
||||||
|
|
||||||
sql = '''SELECT
|
sql = '''SELECT
|
||||||
download.id,
|
download.id,
|
||||||
download.url,
|
download.url,
|
||||||
camera.device_id,
|
camera.device_id,
|
||||||
download.start_timestamp,
|
download.start_timestamp,
|
||||||
download.end_timestamp,
|
download.end_timestamp,
|
||||||
download.status
|
download.status
|
||||||
FROM
|
FROM
|
||||||
camera
|
camera
|
||||||
JOIN download ON download.camera_id = camera.id
|
JOIN download ON download.camera_id = camera.id
|
||||||
JOIN USER ON camera.user_id = user.id
|
JOIN USER ON camera.user_id = user.id
|
||||||
WHERE
|
WHERE
|
||||||
download.status == ?
|
download.status == ?
|
||||||
AND camera.device_id == ?
|
AND camera.device_id == ?
|
||||||
ORDER BY download.start_timestamp
|
ORDER BY download.start_timestamp
|
||||||
LIMIT 10000;'''
|
LIMIT 10000;'''
|
||||||
|
|
||||||
results = cur.execute(sql, ('new', current_camera.id))
|
results = cur.execute(sql, ('new', current_camera.id))
|
||||||
|
|
||||||
# Here is where we send the list of files to be run in the multiprocessing pool
|
|
||||||
run([results, een, current_camera])
|
|
||||||
|
|
||||||
|
# Here is where we send the list of files to be run in the multiprocessing pool
|
||||||
|
run([results, een, current_camera])
|
||||||
|
else:
|
||||||
|
logging.info(f"failed to login for {user_email}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue