notebook
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Spusti blokujici ingest na serveru (docker exec drzeny pres paramiko).
|
||||
Loguje progress kazdych 30s. Idempotentni - hotove slozky preskoci."""
|
||||
import sys
|
||||
import time
|
||||
import paramiko
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("192.168.1.76", username="root", password="7309208104", timeout=10)
|
||||
|
||||
cmd = (
|
||||
"docker exec -e PYTHONIOENCODING=utf-8 python-runner "
|
||||
"python -u /scripts/MailStore/mailstore_ingest_v1.0.py "
|
||||
"vladimir.buzalka@buzalka.cz --since 2020 "
|
||||
"--log-file /scripts/MailStore/ingest_full.log "
|
||||
"--checkpoint /scripts/MailStore/ingest_done.txt"
|
||||
)
|
||||
|
||||
tr = c.get_transport()
|
||||
ch = tr.open_session()
|
||||
ch.exec_command(cmd)
|
||||
|
||||
t0 = time.time()
|
||||
buf = b""
|
||||
while not ch.exit_status_ready():
|
||||
while ch.recv_ready():
|
||||
buf += ch.recv(65536)
|
||||
time.sleep(30)
|
||||
mins = (time.time() - t0) / 60
|
||||
print("[%5.1f min] bezi..." % mins, flush=True)
|
||||
|
||||
while ch.recv_ready():
|
||||
buf += ch.recv(65536)
|
||||
rc = ch.recv_exit_status()
|
||||
print("=== EXIT %d po %.1f min ===" % (rc, (time.time() - t0) / 60), flush=True)
|
||||
sys.stdout.buffer.write(buf[-2000:])
|
||||
c.close()
|
||||
sys.exit(rc)
|
||||
Reference in New Issue
Block a user