diff options
| author | Håkon Solbjørg <hlsolbjorg@gmail.com> | 2019-04-02 00:59:16 +0200 | 
|---|---|---|
| committer | Håkon Solbjørg <hlsolbjorg@gmail.com> | 2019-04-02 19:56:23 +0200 | 
| commit | eb5106409259144159c46cd4c2470621f4d6abe9 (patch) | |
| tree | 4b166da9aa5264e4722d51d1c11a2e6d2e5c5132 /cables.py | |
| parent | 1ceefd7d700caf18f2390b94aa81d9f0207a4d85 (diff) | |
feat: Make it possible to configure the labler from the CLI 🚂
Diffstat (limited to 'cables.py')
| -rw-r--r-- | cables.py | 22 | 
1 files changed, 19 insertions, 3 deletions
@@ -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)  | 
