Skip to content

Commit

Permalink
Merge pull request Pidgeot#3 from McArcady/fix-python3-terminal-handling
Browse files Browse the repository at this point in the history
terminal: decode output of sub-processes from bytes to unicode
  • Loading branch information
Pidgeot authored Apr 4, 2020
2 parents de88aea + 94347e5 commit e89eeb4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def detect():
def get_command_line():
s = subprocess.check_output(
['kreadconfig', '--file', 'kdeglobals', '--group', 'General',
'--key', 'TerminalApplication', '--default', 'konsole']).replace(
'--key', 'TerminalApplication', '--default', 'konsole']).decode('utf-8').replace(
'\n', '')
return ['nohup', s, '-e']

Expand Down Expand Up @@ -159,23 +159,23 @@ def get_command_line():
term = subprocess.check_output([
'gsettings', 'get',
'org.gnome.desktop.default-applications.terminal', 'exec'
]).replace('\n', '').replace("'", '')
]).decode('utf-8').replace('\n', '').replace("'", '')
term_arg = subprocess.check_output([
'gsettings', 'get',
'org.gnome.desktop.default-applications.terminal', 'exec-arg'
]).replace('\n', '').replace("'", '')
]).decode('utf-8').replace('\n', '').replace("'", '')
return ['nohup', term, term_arg]
except: #fallback to older gconf
pass
try:
term = subprocess.check_output([
'gconftool-2', '--get',
'/desktop/gnome/applications/terminal/exec'
]).replace('\n', '')
]).decode('utf-8').replace('\n', '')
term_arg = subprocess.check_output([
'gconftool-2', '--get',
'/desktop/gnome/applications/terminal/exec_arg'
]).replace('\n', '')
]).decode('utf-8').replace('\n', '')
return ['nohup', term, term_arg]
except:
raise Exception("Unable to determine terminal command.")
Expand All @@ -188,7 +188,7 @@ class XfceTerminal(LinuxTerminal):
def detect():
try:
s = subprocess.check_output(
['ps', '-eo', 'comm='], stderr=subprocess.STDOUT)
['ps', '-eo', 'comm='], stderr=subprocess.STDOUT).decode('utf-8')
return 'xfce' in s
except:
return False
Expand Down Expand Up @@ -364,7 +364,7 @@ def _terminal_test_report(fn, value):
while True:
try:
with open(fn, 'w+b') as f:
f.write(str(value))
f.write(str(value).encode('utf-8'))
return
except IOError:
pass
Expand Down

0 comments on commit e89eeb4

Please sign in to comment.