From eb5106409259144159c46cd4c2470621f4d6abe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Tue, 2 Apr 2019 00:59:16 +0200 Subject: =?UTF-8?q?feat:=20Make=20it=20possible=20to=20configure=20the=20l?= =?UTF-8?q?abler=20from=20the=20CLI=20=F0=9F=9A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cables.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'cables.py') diff --git a/cables.py b/cables.py index 9226d88..a7ff5de 100644 --- a/cables.py +++ b/cables.py @@ -65,7 +65,23 @@ def write_csv(data, outfile="cable_labels.csv", split_per_num=100): len(split_data), outfile.replace(".", "-1."))) -def make_cable_labels(switches, uplinks=3): +def read_aps_file(path): + aps = [] + with open(path, "r") as f: + aps = [line.replace("\n", "").strip() for line in f.readlines()] + + return aps + + +def make_cable_labels(switches, ap_file=None, aps=[], copies=2, outfile="cable_labels.csv", split_per_num=100, uplinks=3): print("Generating labels for cables") - labels = generate_labels(switches, uplinks=uplinks, aps=[]) - write_csv(labels) + + list_of_aps = aps + if ap_file: + list_of_aps.extend(read_aps_file(ap_file)) + + if len(list_of_aps): + print("Generating labels for {} APs".format(len(list_of_aps))) + + labels = generate_labels(switches, copies=copies, uplinks=uplinks, aps=aps) + write_csv(labels, outfile=outfile, split_per_num=split_per_num) -- cgit v1.2.3