lint: Fix a bunch of bare-except warnings
This commit is contained in:
		@@ -76,7 +76,7 @@ def get_icmp_low_high(icmpstring):
 | 
				
			|||||||
        icmp = int(icmpstring)
 | 
					        icmp = int(icmpstring)
 | 
				
			||||||
        if icmp > 0:
 | 
					        if icmp > 0:
 | 
				
			||||||
            return icmp, icmp
 | 
					            return icmp, icmp
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if icmpstring.startswith("-"):
 | 
					    if icmpstring.startswith("-"):
 | 
				
			||||||
@@ -90,7 +90,7 @@ def get_icmp_low_high(icmpstring):
 | 
				
			|||||||
    try:
 | 
					    try:
 | 
				
			||||||
        icmps = icmpstring.split("-")
 | 
					        icmps = icmpstring.split("-")
 | 
				
			||||||
        return int(icmps[0]), int(icmps[1])
 | 
					        return int(icmps[0]), int(icmps[1])
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return None, None
 | 
					    return None, None
 | 
				
			||||||
@@ -110,13 +110,13 @@ def get_port_low_high(portstring):
 | 
				
			|||||||
        port = int(portstring)
 | 
					        port = int(portstring)
 | 
				
			||||||
        if port > 0:
 | 
					        if port > 0:
 | 
				
			||||||
            return port, port
 | 
					            return port, port
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        port = socket.getservbyname(portstring)
 | 
					        port = socket.getservbyname(portstring)
 | 
				
			||||||
        return port, port
 | 
					        return port, port
 | 
				
			||||||
    except:
 | 
					    except OSError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if portstring.startswith("-"):
 | 
					    if portstring.startswith("-"):
 | 
				
			||||||
@@ -130,7 +130,7 @@ def get_port_low_high(portstring):
 | 
				
			|||||||
    try:
 | 
					    try:
 | 
				
			||||||
        ports = portstring.split("-")
 | 
					        ports = portstring.split("-")
 | 
				
			||||||
        return int(ports[0]), int(ports[1])
 | 
					        return int(ports[0]), int(ports[1])
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return None, None
 | 
					    return None, None
 | 
				
			||||||
@@ -144,7 +144,7 @@ def is_ip(ip_string):
 | 
				
			|||||||
    try:
 | 
					    try:
 | 
				
			||||||
        _ = ipaddress.ip_network(ip_string, strict=False)
 | 
					        _ = ipaddress.ip_network(ip_string, strict=False)
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    return False
 | 
					    return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -190,13 +190,13 @@ def get_protocol(protostring):
 | 
				
			|||||||
        proto = int(protostring)
 | 
					        proto = int(protostring)
 | 
				
			||||||
        if proto > 0:
 | 
					        if proto > 0:
 | 
				
			||||||
            return proto
 | 
					            return proto
 | 
				
			||||||
    except:
 | 
					    except ValueError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        proto = socket.getprotobyname(protostring)
 | 
					        proto = socket.getprotobyname(protostring)
 | 
				
			||||||
        return proto
 | 
					        return proto
 | 
				
			||||||
    except:
 | 
					    except OSError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return None
 | 
					    return None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -790,10 +790,7 @@ def validate_interfaces(yaml):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def is_mpls(yaml, ifname):
 | 
					def is_mpls(yaml, ifname):
 | 
				
			||||||
    """Returns True if the interface exists and has mpls enabled. Returns false otherwise."""
 | 
					    """Returns True if the interface exists and has mpls enabled. Returns false otherwise."""
 | 
				
			||||||
    ifname, iface = get_by_name(yaml, ifname)
 | 
					    _, iface = get_by_name(yaml, ifname)
 | 
				
			||||||
    try:
 | 
					    if iface and "mpls" in iface and iface["mpls"]:
 | 
				
			||||||
        if iface["mpls"]:
 | 
					        return True
 | 
				
			||||||
            return True
 | 
					 | 
				
			||||||
    except:
 | 
					 | 
				
			||||||
        pass
 | 
					 | 
				
			||||||
    return False
 | 
					    return False
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,10 +152,7 @@ def validate_loopbacks(yaml):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def is_mpls(yaml, ifname):
 | 
					def is_mpls(yaml, ifname):
 | 
				
			||||||
    """Returns True if the loopback exists and has mpls enabled. Returns false otherwise."""
 | 
					    """Returns True if the loopback exists and has mpls enabled. Returns false otherwise."""
 | 
				
			||||||
    ifname, iface = get_by_name(yaml, ifname)
 | 
					    _, iface = get_by_name(yaml, ifname)
 | 
				
			||||||
    try:
 | 
					    if iface and "mpls" in iface and iface["mpls"]:
 | 
				
			||||||
        if iface["mpls"]:
 | 
					        return True
 | 
				
			||||||
            return True
 | 
					 | 
				
			||||||
    except:
 | 
					 | 
				
			||||||
        pass
 | 
					 | 
				
			||||||
    return False
 | 
					    return False
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user