aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-06 03:37:23 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-08 06:50:13 +0000
commit879d5677d2312a87dce030dc46d9f621a308ed2c (patch)
treed1b0174d317ca82a3b9a06f16401e40d9efca47b /test/mocks
parent1b6431d1928dd532271ed6a109622a7b44394c36 (diff)
Supress ANSI escape sequences when terminal not detected
This prevents obscured output when redirecting output to a file descriptor. Change-Id: Ie56b6f65b1d2adffc69d3f75a9c8f98c0444faa8 Issue-ID: INT-1577 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks')
-rwxr-xr-xtest/mocks/mass-pnf-sim/mass-pnf-sim.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/mocks/mass-pnf-sim/mass-pnf-sim.py b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
index c4fb0ded8..db567ede0 100755
--- a/test/mocks/mass-pnf-sim/mass-pnf-sim.py
+++ b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
@@ -8,8 +8,6 @@ import logging
from requests import get
from requests.exceptions import MissingSchema, InvalidSchema, InvalidURL, ConnectionError, ConnectTimeout
-logging.basicConfig(level=logging.INFO, format='\033[92m[%(levelname)s]\033[0m %(message)s')
-
def validate_url(url):
'''Helper function to perform --urlves input param validation'''
logger = logging.getLogger("urllib3")
@@ -31,6 +29,11 @@ def validate_ip(ip):
else:
return ip_valid
+if sys.stdout.isatty():
+ logging.basicConfig(level=logging.INFO, format='\033[92m[%(levelname)s]\033[0m %(message)s')
+else:
+ logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s')
+
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', help='Bootstrap the system', type=int, metavar='COUNT')
parser.add_argument('--trigger', help='Trigger one single VES event from each simulator', type=int,
@@ -52,6 +55,7 @@ parser.add_argument('--verbose', help='Verbosity level', choices=['info', 'debug
type=str, default='debug')
args = parser.parse_args()
+
logger = logging.getLogger(__name__)
logger.setLevel(getattr(logging, args.verbose.upper()))