From 26f792f40432af000a234fe0bbc3825829ea5338 Mon Sep 17 00:00:00 2001 From: Sheng Date: Thu, 9 Nov 2017 10:58:28 +0800 Subject: [PATCH] Use io.StringIO --- main.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 3e29658..5989be5 100644 --- a/main.py +++ b/main.py @@ -1,19 +1,15 @@ +import io import logging import os.path import socket -import weakref import uuid +import weakref import paramiko import tornado.web import tornado.websocket from tornado.ioloop import IOLoop from tornado.options import define, options, parse_command_line -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO - define('address', default='127.0.0.1', help='listen address') define('port', default=8888, help='listen port', type=int) @@ -109,10 +105,7 @@ class IndexHandler(tornado.web.RequestHandler): if not password: password = None - try: - spkey = StringIO(privatekey) - except TypeError: - spkey = StringIO(privatekey.decode('utf-8')) + spkey = io.StringIO(privatekey.decode('utf-8')) try: pkey = paramiko.RSAKey.from_private_key(spkey, password=password)