Use io.StringIO

pull/4/head
Sheng 2017-11-09 10:58:28 +08:00
parent 80e559dba4
commit 26f792f404
1 changed files with 3 additions and 10 deletions

13
main.py
View File

@ -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)