lf_atten_mod_test.py : port needs to be fully removed put in a work around

Added the logger information.

Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
Chuck SmileyRekiere
2022-05-05 14:07:08 -06:00
committed by shivam
parent 4290da5f57
commit f153a8576b

View File

@@ -7,8 +7,8 @@ This program is used to modify the LANforge attenuator (through the LANforge man
You can check the attenuator details and serial number by using show() method.
EXAMPLE:
Run with all serial number and module: python3 lf_atten_mod_test.py -hst 192.168.200.12 -port 8080 -atten_serno all --atten_idx all --atten_val 220
Run with particular serial number(2222) and module(2): python3 lf_atten_mod_test.py -hst 192.168.200.12 -port 8080 -atten_serno 2222 --atten_idx 3 --atten_val 220
Run with all serial number and module: python3 lf_atten_mod_test.py -hst 192.168.200.12 -atten_serno all --atten_idx all --atten_val 220
Run with particular serial number(2222) and module(2): python3 lf_atten_mod_test.py -hst 192.168.200.12 -atten_serno 2222 --atten_idx 3 --atten_val 220
"atten_serno" = serial number
"atten_idx" = module name
@@ -22,6 +22,8 @@ import sys
import os
import importlib
import argparse
import logging
if sys.version_info[0] != 3:
print("This script requires Python 3")
@@ -33,6 +35,10 @@ sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
realm = importlib.import_module("py-json.realm")
Realm = realm.Realm
logger = logging.getLogger(__name__)
lf_logger_config = importlib.import_module("py-scripts.lf_logger_config")
class CreateAttenuator(Realm):
def __init__(self, host, port, serno, idx, val,
@@ -41,7 +47,6 @@ class CreateAttenuator(Realm):
_exit_on_fail=False):
super().__init__(host, port, debug_=_debug_on, _exit_on_fail=_exit_on_fail)
self.host = host
self.port = port
self.serno = serno
self.idx = idx
self.val = val
@@ -65,19 +70,27 @@ def main():
lf_atten_mod_test.py
--------------------
set and show Attenuator:
python3 lf_atten_mod_test.py --hst 192.168.200.12 --port 8080 -atten_serno all --atten_idx 7 --atten_val 220
python3 lf_atten_mod_test.py --hst 192.168.200.12 --atten_serno all --atten_idx 7 --atten_val 220
''')
parser.add_argument('-hst', '--host', help='host name', default='192.168.200.12')
# basic_argparser contains --port option
# Realm requires a port to be passed in
# parser.add_argument('-port', '--port', help='port name', default=8080)
parser.add_argument('-atten_serno', '--atten_serno', help='Serial number for requested Attenuator, or \'all\'', default=2222)
parser.add_argument('-atten_idx', '--atten_idx', help='Attenuator index eg. For module 1 = 0,module 2 = 1', default=7)
parser.add_argument('-atten_val', '--atten_val', help='Requested attenution in 1/10ths of dB (ddB).', default=550)
args = parser.parse_args()
atten_mod_test = CreateAttenuator(host=args.host, port=args.port, serno=args.atten_serno, idx=args.atten_idx, val=args.atten_val)
# set up logger
logger_config = lf_logger_config.lf_logger_config()
# set the logger level to requested value
logger_config.set_level(level=args.log_level)
logger_config.set_json(json_file=args.lf_logger_config_json)
# TODO the attenuator does not need port need to clean up. 5/5/22
args.port = 8080
atten_mod_test = CreateAttenuator(host=args.host, port=args.port, serno=args.atten_serno, idx=args.atten_idx, val=args.atten_val, _debug_on=args.debug)
atten_mod_test.build()