Do not use base except: clauses

https://docs.python.org/2/howto/doanddont.html#except

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2017-11-10 05:18:32 -05:00
parent ade9d61c22
commit 3c1655322d
9 changed files with 46 additions and 37 deletions
+2 -2
View File
@@ -63,9 +63,9 @@ if __name__ == '__main__':
(opts, args) = parser.parse_args()
try:
if len(args) != 1: raise
if len(args) != 1: raise ValueError
opts.listen_port = int(args[0])
except:
except ValueError:
parser.error("Invalid arguments")
logging.basicConfig(level=logging.INFO)
+2 -3
View File
@@ -12,10 +12,9 @@ from websockify.websocket import WebSocket, \
parser = optparse.OptionParser(usage="%prog URL")
(opts, args) = parser.parse_args()
try:
if len(args) != 1: raise
if len(args) == 1:
URL = args[0]
except:
else:
parser.error("Invalid arguments")
sock = WebSocket()
+4 -4
View File
@@ -105,7 +105,7 @@ class WebSocketLoad(WebSockifyRequestHandler):
cnt = int(cnt)
length = int(length)
chksum = int(chksum)
except:
except ValueError:
print "\n<BOF>" + repr(data) + "<EOF>"
err += "Invalid data format\n"
continue
@@ -148,16 +148,16 @@ if __name__ == '__main__':
(opts, args) = parser.parse_args()
try:
if len(args) != 1: raise
if len(args) != 1: raise ValueError
opts.listen_port = int(args[0])
if len(args) not in [1,2]: raise
if len(args) not in [1,2]: raise ValueError
opts.listen_port = int(args[0])
if len(args) == 2:
opts.delay = int(args[1])
else:
opts.delay = 10
except:
except ValueError:
parser.error("Invalid arguments")
logging.basicConfig(level=logging.INFO)