read timeout in config

This commit is contained in:
s.mostryukov 2025-06-19 13:56:32 +03:00
parent e80821e6da
commit 49e62892c8
3 changed files with 3 additions and 1 deletions

View File

@ -73,7 +73,7 @@ def connect_to_device(vendor: str, host: str, name: str="") -> ConnectHandler:
def send_command(connection: ConnectHandler, command: str) -> str: def send_command(connection: ConnectHandler, command: str) -> str:
try: try:
result: str = connection.send_command(command, read_timeout=30) result: str = connection.send_command(command, read_timeout=cfg.net_dev.read_timeout)
except exceptions.NetmikoTimeoutException: except exceptions.NetmikoTimeoutException:
result = "NetmikoTimeoutException" result = "NetmikoTimeoutException"
except exceptions.ReadTimeout: except exceptions.ReadTimeout:

View File

@ -67,6 +67,7 @@ class ConfigNetDev:
domain: str = os.getenv("NET_DEV_DOMAIN") domain: str = os.getenv("NET_DEV_DOMAIN")
pwd: str = os.getenv("NET_DEV_PWD") pwd: str = os.getenv("NET_DEV_PWD")
ssh_port: int = config["net_dev"].getint("ssh_port") ssh_port: int = config["net_dev"].getint("ssh_port")
read_timeout: int = config["net_dev"].getint("read_timeout")
@dataclass @dataclass

View File

@ -39,6 +39,7 @@ start_at: 18:59
[net_dev] [net_dev]
# Порт на который подключаться по ssh # Порт на который подключаться по ssh
ssh_port: 22 ssh_port: 22
read_timeout: 30
[log] [log]
# Уровень логов в консоль # Уровень логов в консоль