Set utf-8 as the default encoding if we cannot detect it

pull/144/head
Sheng 2020-03-22 14:40:49 +08:00
parent 795875807b
commit 5f4978a994
1 changed files with 10 additions and 6 deletions

View File

@ -427,12 +427,16 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
] ]
for command in commands: for command in commands:
_, stdout, _ = ssh.exec_command(command, get_pty=True) try:
data = stdout.read() _, stdout, _ = ssh.exec_command(command, get_pty=True)
logging.debug('{!r} => {!r}'.format(command, data)) except paramiko.SSHException as exc:
result = self.parse_encoding(data) logging.info(str(exc))
if result: else:
return result data = stdout.read()
logging.debug('{!r} => {!r}'.format(command, data))
result = self.parse_encoding(data)
if result:
return result
logging.warn('Could not detect the default ecnoding.') logging.warn('Could not detect the default ecnoding.')
return 'utf-8' return 'utf-8'