Skip to content
Snippets Groups Projects
Commit 3bc685b0 authored by Leonard Penzer's avatar Leonard Penzer
Browse files

restrict hostname to ascii characters

Avoids this error on certain hostnames:
UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 24: ordinal not in range(128)
parent 467d0d33
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,9 @@ ap = argparse.ArgumentParser() ...@@ -15,6 +15,9 @@ ap = argparse.ArgumentParser()
ap.add_argument("--raw", type=argparse.FileType("r", encoding="utf-8"), required=True) ap.add_argument("--raw", type=argparse.FileType("r", encoding="utf-8"), required=True)
args = ap.parse_args() args = ap.parse_args()
def filterNonAscii(s):
return s.encode("ascii", errors="ignore").decode()
def getHardwareModelFromEntry(d): def getHardwareModelFromEntry(d):
try: try:
hardware_model = d["nodeinfo"]["hardware"]["model"] hardware_model = d["nodeinfo"]["hardware"]["model"]
...@@ -116,7 +119,7 @@ for download in allFirmwareDownloads: ...@@ -116,7 +119,7 @@ for download in allFirmwareDownloads:
hostname = d["nodeinfo"]["hostname"] hostname = d["nodeinfo"]["hostname"]
hardware_model = getHardwareModelFromEntry(d) hardware_model = getHardwareModelFromEntry(d)
if currentRelease < r.release: if currentRelease < r.release:
print("%s (%s) %s -> %s Segment %i %s status %s @ %s" % (mac, hostname, currentRelease, r.release, r.segment, hardware_model, status, r.date)) print("%s (%s) %s -> %s Segment %i %s status %s @ %s" % (mac, filterNonAscii(hostname), currentRelease, r.release, r.segment, hardware_model, status, r.date))
else: else:
#request = requests.get(MAC_URL % mac) #request = requests.get(MAC_URL % mac)
#pprint.pprint(request.json()) #pprint.pprint(request.json())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment