Select Git revision
data_mover_rpi7.py
-
Jiří Kalvoda authoredJiří Kalvoda authored
data_mover_rpi7.py 1.06 KiB
#!/usr/bin/env python3
import communication
from communication import dt_to_path
import asyncio
import datetime
import sys, os
import pathlib
import data_utils
async def main():
#s = await SSHRunSocket().connect('ssh localhost "/dev/stderr"')
#s = await SSHRunSocket().connect('ssh localhost "tee /dev/stderr"')
s = await communication.SSHRunSocket().connect('ssh jr@externalArch.jk.dyn.blatto.eu /mnt/jr/jr/prog/run_py admin_server.py')
c = communication.AdminServer(s)
#await s.write(b"Ahoj!")
for dt in await c.list_realtime_data(datetime.datetime(2023, 1, 1, 0, 0), datetime.datetime(2100, 1, 1, 0, 0)):
path = "data/realtime/"+dt_to_path(dt)
if not (os.path.isdir(path) or os.path.isfile(path+".json.zst") or os.path.isfile(path+".json.gzip")):
print("WILL DOWNLOAD", path)
data_utils.write_data(dt, await c.get_data(dt))
if (datetime.datetime.now(communication.local_timezone)-dt).total_seconds() > 60*60*24 * 250:
print("REMOVE", path)
await c.remove_data(dt)
asyncio.run(main())