First attempt with arguments.

This commit is contained in:
Adrian Woodley
2019-07-23 02:35:48 +08:00
parent 60cd427357
commit 687c6fef0d

View File

@@ -26,7 +26,10 @@ VLAN = 4095
ARG_PARSER = argparse.ArgumentParser(
description='Scriptable configuration of Aviat Eclipse INUes.')
ARG_PARSER.add_argument('csv')
ARG_PARSER.add_argument('--in', action="store", dest="in_file")
ARG_PARSER.add_argument('--out', action="store", dest="out_file", default="passed.csv")
ARG_PARSER.add_argument('--area', action="store", dest="ospf_area", default=None)
arguments = ARG_PARSER.parse_args()
@dataclass
class INUeCommand():
@@ -123,7 +126,6 @@ class Worker(threading.Thread):
for command in commands:
if not send_config(telnet, command):
print(command.get_command())
self.__failed.put(inue)
fail = True
break
@@ -189,7 +191,7 @@ def passed_output():
count = WORKERS
field_names = ['IP Address']
with open('/tmp/aviat.csv', 'w', newline='') as out_file:
with open(OUTFILEPATH, 'w', newline='') as out_file:
csv_writer = csv.DictWriter(out_file, fieldnames=field_names,
delimiter=',', quotechar='"',
quoting=csv.QUOTE_MINIMAL)
@@ -225,7 +227,9 @@ FAILED_QUEUE = queue.Queue(0)
# for i in range(WORKERS):
# INUE_QUEUE.put(None)
INFILEPATH = sys.argv[1]
# INFILEPATH = sys.argv[1]
INFILEPATH = arguments.in_file
OUTFILEPATH = arguments.out_file
input_inues()