#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Kolik 2020+ zprav z problemovych slozek uz je v Mongo (dle mailstore_folder).""" import sys, paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("192.168.1.76", username="root", password="7309208104", timeout=10) py = r''' from pymongo import MongoClient from datetime import datetime, timezone m=MongoClient("mongodb://192.168.1.76:27017") col=m["emaily"]["vladimir.buzalka@buzalka.cz"] since=datetime(2020,1,1,tzinfo=timezone.utc) # vsechny distinct mailstore_folder hodnoty obsahujici tyto nazvy for needle in ["Odstranen", "/Doru", "OPTUM_PATROc", "27646"]: folders=[f for f in col.distinct("mailstore_folder") if f and needle in f] print("== needle:", needle, "->", len(folders), "slozek") for label, q in [ ("Odstranena posta (top)", {"mailstore_folder":{"$regex":"/Odstran[^/]*$"}}), ("Dorucena posta (top)", {"mailstore_folder":{"$regex":"/Doru[^/]*posta$"}}), ]: tot=col.count_documents(dict(q, source="mailstore")) new=col.count_documents(dict(q, source="mailstore", sent_at={"$gte":since})) print(f"{label}: mailstore={tot} 2020+={new}") ''' i, o, e = c.exec_command('docker exec python-runner python -c %r' % py) sys.stdout.buffer.write(o.read()); sys.stdout.buffer.write(e.read()) c.close()