--credentials required

This commit is contained in:
boyska 2022-03-15 18:47:54 +01:00
parent e1790932f3
commit e3d25bbdb8

View file

@ -1,5 +1,7 @@
import asyncio import asyncio
import logging import logging
import pathlib
from typing import Tuple
from panoramisk import Manager from panoramisk import Manager
@ -12,6 +14,7 @@ def add_arguments(p):
default="INFO", default="INFO",
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
) )
p.add_argument("--credentials", type=pathlib.Path, required=True)
return p return p
@ -20,15 +23,23 @@ def do_common_options(args):
logging.getLogger("panoramisk.manager").setLevel(logging.WARNING) logging.getLogger("panoramisk.manager").setLevel(logging.WARNING)
def read_credentials(fpath) -> Tuple[str, str]:
with fpath.open() as buf:
username = buf.readline().rstrip("\n\r")
password = buf.readline().rstrip("\n\r")
return username, password
def get_manager(args): def get_manager(args):
username, password = read_credentials(args.credentials)
manager = Manager( manager = Manager(
loop=LOOP, loop=LOOP,
host="127.0.0.1", host="127.0.0.1",
port=5038, port=5038,
ssl=False, ssl=False,
encoding="utf8", encoding="utf8",
username="ring", username=username,
secret="campanellino", secret=password,
ping_delay=10, # Delay after start ping_delay=10, # Delay after start
ping_interval=10, # Periodically ping AMI (dead or alive) ping_interval=10, # Periodically ping AMI (dead or alive)
reconnect_timeout=2, # Timeout reconnect if connection lost reconnect_timeout=2, # Timeout reconnect if connection lost