From 909ae889eead6e15213962ee7706088feb0dcdc1 Mon Sep 17 00:00:00 2001 From: thevickypedia Date: Mon, 10 Jan 2022 22:21:29 -0600 Subject: [PATCH] Disable printing final config when logged in a file --- CHANGELOG | 4 ++++ version.py | 2 +- vpn/helper.py | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0591f90..d424e02 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ Change Log ========== +0.5.2 (01/10/2022) +------------------ +- Disable printing final config when logged in a file + 0.5.1 (01/10/2022) ------------------ - Change configuration input to match regex diff --git a/version.py b/version.py index 3c2e7d4..fdaa4e9 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -version_info = (0, 5, 1) +version_info = (0, 5, 2) diff --git a/vpn/helper.py b/vpn/helper.py index a375c2d..e81819c 100644 --- a/vpn/helper.py +++ b/vpn/helper.py @@ -123,7 +123,12 @@ def interactive_ssh(hostname: str, username: str, pem_file: str, logger: logging elif isinstance(response, tuple): logger.info(f"Sending {response[0]}") interact.send(send_string=response[0]) - sys.stdout = sys.__stdout__ - interact.expect(timeout=timeout) # Expect comes after releasing print, so the final stages of config gets printed - ssh_client.close() + if 'FILE' in str(logger): + interact.expect(timeout=timeout) + sys.stdout = sys.__stdout__ + ssh_client.close() + else: + sys.stdout = sys.__stdout__ + interact.expect(timeout=timeout) + ssh_client.close() return True