From ef5dd083cba8da245e90a5203ba83622fed0eaee Mon Sep 17 00:00:00 2001 From: Mikaela Suomalainen Date: Mon, 11 Oct 2021 10:51:25 +0300 Subject: [PATCH] ssid-valid-len.py: attempt adding _nomap counting Ref: #31 --- python/ssid-valid-len.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/python/ssid-valid-len.py b/python/ssid-valid-len.py index b484ecb..5dd1330 100755 --- a/python/ssid-valid-len.py +++ b/python/ssid-valid-len.py @@ -5,15 +5,26 @@ This script asks for a SSID name, counts it and tells whether it's of valid length ''' -# Request input -givenssid = input("Please enter the SSID you are thinking of: ") -#givenssid = "test_nomap" +# Request input or assume "test" on empty. +givenssid = str(input("Please enter the SSID you are thinking of (preferably 26 chars to fit _nomap): ") or "test") # Ensure it's UTF-8 and store the size. E.g. åäö are longer than oao +# TODO: make this a function too givenssidlen = len(givenssid.encode("utf8")) -# 32 bytes should be the maximum SSID length -if givenssidlen <= 32: - print(givenssid, "is", givenssidlen, "long and thus valid length") -else: - print("Too long, try again") +# Checking the SSID length is done twice, so thus a function +def checkssidlen(givenssidlen): + # 32 bytes should be the maximum SSID length + if givenssidlen <= 32: + print(givenssid, "is", givenssidlen, "long and thus valid length") + else: + print(givenssid, "is", givenssidlen, "to long, please select a different SSID") + +# Checking the SSID without _nomap +checkssidlen(givenssidlen) +# TODO: make this a function too +givenssidlen = len(givenssid.encode("utf8")) + +# Continuing with _nomap to ensure it also fits +givenssid = givenssid + "_nomap" +checkssidlen(givenssidlen)