From 439e0e3e12875c9e5e0e5cfb2a60d390f7278bdb Mon Sep 17 00:00:00 2001 From: Benjamin Collet Date: Mon, 16 Nov 2020 09:04:22 +0100 Subject: [PATCH] FIX: SyntaxWarning Only remove last part of FQDN on short hostname --- client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client.py b/client.py index 48fecbd..d8548b1 100755 --- a/client.py +++ b/client.py @@ -21,7 +21,7 @@ def call_api(params, path): except: return - if response.status_code is not 200: + if response.status_code != 200: return return response.json() @@ -88,7 +88,8 @@ def search_ports(args): if device['disabled'] == "1": continue if args.short: - short_hostname = device['hostname'].split(".",1)[0] + #short_hostname = device['hostname'].split(".",1)[0] + short_hostname = ".".join(device['hostname'].split(".")[0:-1]) print("(0x(B %-25.25s (0x(B %-16.16s (0x(B %-5.5s (0x(B %-*.*s (0x(B" % (short_hostname, port['port_label_short'], port['ifOperStatus'], value_cols, value_cols, port['ifAlias'])) @@ -164,7 +165,7 @@ def search_devices(args): if device['disabled'] == "1": continue if args.short: - short_hostname = device['hostname'].split(".",1)[0] + short_hostname = ".".join(device['hostname'].split(".")[0:-1]) print("(0x(B %-25.25s (0x(B %-26.26s (0x(B %-*.*s (0x(B" % (short_hostname, " ".join([device['vendor'] or "", device['hardware'] or ""]),