adapt bluemaestro to use my_configuration
This commit is contained in:
parent
9ba2cf6a92
commit
367ecca2a1
2 changed files with 10 additions and 12 deletions
|
@ -7,24 +7,20 @@ from pathlib import Path
|
||||||
from typing import Any, Dict, Iterable, NamedTuple, Set
|
from typing import Any, Dict, Iterable, NamedTuple, Set
|
||||||
|
|
||||||
from cachew import cachew
|
from cachew import cachew
|
||||||
|
|
||||||
|
# TODO move to common??
|
||||||
from kython import dictify
|
from kython import dictify
|
||||||
|
|
||||||
|
# TODO vendorize in my. pkg? It's quite handy...
|
||||||
from kython.klogging import LazyLogger
|
from kython.klogging import LazyLogger
|
||||||
|
|
||||||
|
from my_configuration import paths
|
||||||
CACHE = Path('/L/data/.cache/bluemaestro.cache')
|
|
||||||
|
|
||||||
DIR = Path("/L/zzz_syncthing_backups/bluemaestro-all/")
|
|
||||||
# TODO how to move them back?
|
|
||||||
DIR2 = Path("/L/zzz_syncthing_phone/phone-syncthing/backups/bluemaestro/")
|
|
||||||
|
|
||||||
logger = LazyLogger('bluemaestro', level=logging.DEBUG)
|
logger = LazyLogger('bluemaestro', level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
def get_backup_files():
|
def get_backup_files():
|
||||||
return list(sorted(chain(
|
return list(sorted(chain.from_iterable(d.glob('*.db') for d in paths.bluemaestro.export_paths)))
|
||||||
DIR.glob('*.db'),
|
|
||||||
DIR2.glob('*.db'),
|
|
||||||
)))
|
|
||||||
|
|
||||||
|
|
||||||
class Point(NamedTuple):
|
class Point(NamedTuple):
|
||||||
|
@ -32,7 +28,8 @@ class Point(NamedTuple):
|
||||||
temp: float
|
temp: float
|
||||||
|
|
||||||
|
|
||||||
@cachew(cache_path=CACHE)
|
# TODO hmm, does cachew have py.typed?
|
||||||
|
@cachew(cache_path=paths.bluemaestro.cache)
|
||||||
def iter_points(dbs) -> Iterable[Point]:
|
def iter_points(dbs) -> Iterable[Point]:
|
||||||
# I guess we can affort keeping them in sorted order
|
# I guess we can affort keeping them in sorted order
|
||||||
points: Set[Point] = set()
|
points: Set[Point] = set()
|
||||||
|
@ -78,7 +75,7 @@ def get_temperature(backups=get_backup_files()):
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
get_temperature(get_backup_files()[-1:])
|
print(get_temperature(get_backup_files()[-1:]))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ll = list(iter_points(get_backup_files()))
|
ll = list(iter_points(get_backup_files()))
|
||||||
|
|
|
@ -5,6 +5,7 @@ from kython import setup_logzero
|
||||||
|
|
||||||
from my.bluemaestro import get_temperature, logger
|
from my.bluemaestro import get_temperature, logger
|
||||||
|
|
||||||
|
# TODO move this to backup checker?
|
||||||
def main():
|
def main():
|
||||||
temps = get_temperature()
|
temps = get_temperature()
|
||||||
latest = temps[:-2]
|
latest = temps[:-2]
|
||||||
|
|
Loading…
Add table
Reference in a new issue