Skip to content

Commit

Permalink
Fix reprounzip-qt on Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jul 2, 2021
1 parent d9851b5 commit 644fb46
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions reprounzip-qt/reprounzip_qt/qt_terminal.py
Expand Up @@ -4,13 +4,18 @@

from __future__ import division, print_function, unicode_literals

import cgi
import locale
import logging
from qtpy import QtCore, QtWidgets
import sys


if sys.version >= (3,):
from html import escape
else:
from cgi import escape


logger = logging.getLogger('reprounzip_qt')


Expand Down Expand Up @@ -82,7 +87,7 @@ def __init__(self, cmdline, env, input_enabled=False,
</style>
''')
self.text.append('<span style="color: blue;">%s</span>' %
cgi.escape(' '.join(cmdline)))
escape(' '.join(cmdline)))

def _enter(self):
cmd = self.input.text()
Expand All @@ -93,13 +98,13 @@ def _read_stdout(self):
out = self.process.readAllStandardOutput()
out = bytes(out).decode(locale.getpreferredencoding() or 'UTF-8',
'replace')
self.text.append('<span>%s</span>' % cgi.escape(out))
self.text.append('<span>%s</span>' % escape(out))

def _read_stderr(self):
out = self.process.readAllStandardError()
out = bytes(out).decode(locale.getpreferredencoding() or 'UTF-8',
'replace')
self.text.append('<span class="err">%s</span>' % cgi.escape(out))
self.text.append('<span class="err">%s</span>' % escape(out))

def _finished(self, code, status):
good = False
Expand Down

0 comments on commit 644fb46

Please sign in to comment.