From 30a69883925a4ee01b6eb0586e8295fa72458b16 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 22 Jul 2012 12:49:59 +1200 Subject: [PATCH] pathod: handle keyboard interrupts and SSL errors. --- pathoc | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/pathoc b/pathoc index fc76cfc88..70105ced3 100755 --- a/pathoc +++ b/pathoc @@ -49,15 +49,24 @@ if __name__ == "__main__": else: port = args.port - for i in range(args.repeat): - p = pathoc.Pathoc(args.host, port) - try: - p.connect() - except tcp.NetLibError, v: - print >> sys.stderr, str(v) - sys.exit(1) - if args.ssl: - p.convert_to_ssl(sni=args.sni) - if args.timeout: - p.settimeout(args.timeout) - p.print_requests(args.request, args.verbose, args.reqdump) + try: + for i in range(args.repeat): + p = pathoc.Pathoc(args.host, port) + try: + p.connect() + except tcp.NetLibError, v: + print >> sys.stderr, str(v) + sys.exit(1) + if args.ssl: + try: + p.convert_to_ssl(sni=args.sni) + except tcp.NetLibError, v: + print "\n>> %s"%v + continue + if args.timeout: + p.settimeout(args.timeout) + p.print_requests(args.request, args.verbose, args.reqdump) + sys.stdout.flush() + except KeyboardInterrupt: + pass +