Avoid bare exceptions
This commit is contained in:
parent
08b7034d6f
commit
06406fa46c
2 changed files with 6 additions and 6 deletions
|
@ -99,6 +99,6 @@ class UiRequestPlugin(object):
|
||||||
site = self.server.sites[path_parts["address"]]
|
site = self.server.sites[path_parts["address"]]
|
||||||
try:
|
try:
|
||||||
path_parts["address"], path_parts["inner_path"] = getCorsPath(site, path_parts["inner_path"])
|
path_parts["address"], path_parts["inner_path"] = getCorsPath(site, path_parts["inner_path"])
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
return path_parts
|
return path_parts
|
||||||
|
|
|
@ -144,7 +144,7 @@ def getFilename(path):
|
||||||
def getFilesize(path):
|
def getFilesize(path):
|
||||||
try:
|
try:
|
||||||
s = os.stat(path)
|
s = os.stat(path)
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
if stat.S_ISREG(s.st_mode): # Test if it's file
|
if stat.S_ISREG(s.st_mode): # Test if it's file
|
||||||
return s.st_size
|
return s.st_size
|
||||||
|
@ -246,14 +246,14 @@ def isIp(ip):
|
||||||
try:
|
try:
|
||||||
socket.inet_pton(socket.AF_INET6, ip)
|
socket.inet_pton(socket.AF_INET6, ip)
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
else: # IPv4
|
else: # IPv4
|
||||||
try:
|
try:
|
||||||
socket.inet_aton(ip)
|
socket.inet_aton(ip)
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,12 +291,12 @@ def getInterfaceIps(ip_type="ipv4"):
|
||||||
s = createSocket(test_ip, sock_type=socket.SOCK_DGRAM)
|
s = createSocket(test_ip, sock_type=socket.SOCK_DGRAM)
|
||||||
s.connect((test_ip, 1))
|
s.connect((test_ip, 1))
|
||||||
res.append(s.getsockname()[0])
|
res.append(s.getsockname()[0])
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res += [ip[4][0] for ip in socket.getaddrinfo(socket.gethostname(), 1)]
|
res += [ip[4][0] for ip in socket.getaddrinfo(socket.gethostname(), 1)]
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
res = [re.sub("%.*", "", ip) for ip in res if getIpType(ip) == ip_type and isIp(ip)]
|
res = [re.sub("%.*", "", ip) for ip in res if getIpType(ip) == ip_type and isIp(ip)]
|
||||||
|
|
Loading…
Reference in a new issue