From e3d25bbdb80ca4565d5f9f89080db84bdd67fb18 Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 15 Mar 2022 18:47:54 +0100 Subject: [PATCH] --credentials required --- asterisk_misc_common.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/asterisk_misc_common.py b/asterisk_misc_common.py index 6b75169..e2790a9 100644 --- a/asterisk_misc_common.py +++ b/asterisk_misc_common.py @@ -1,5 +1,7 @@ import asyncio import logging +import pathlib +from typing import Tuple from panoramisk import Manager @@ -12,6 +14,7 @@ def add_arguments(p): default="INFO", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], ) + p.add_argument("--credentials", type=pathlib.Path, required=True) return p @@ -20,15 +23,23 @@ def do_common_options(args): 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): + username, password = read_credentials(args.credentials) manager = Manager( loop=LOOP, host="127.0.0.1", port=5038, ssl=False, encoding="utf8", - username="ring", - secret="campanellino", + username=username, + secret=password, ping_delay=10, # Delay after start ping_interval=10, # Periodically ping AMI (dead or alive) reconnect_timeout=2, # Timeout reconnect if connection lost