command.script now unicode

This commit is contained in:
nvbn
2015-04-21 06:24:40 +02:00
parent 0925c7966f
commit 5ccf163594
6 changed files with 13 additions and 12 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ def wait_output(settings, popen):
def get_command(settings, args):
"""Creates command from `args` and executes it."""
script = ' '.join(args[1:])
script = ' '.join(arg.decode('utf-8') for arg in args[1:])
result = Popen(script, shell=True, stdout=PIPE, stderr=PIPE,
env=dict(os.environ, LANG='C'))
if wait_output(settings, result):
+1 -1
View File
@@ -7,5 +7,5 @@ def match(command, settings):
def get_new_command(command, settings):
return './{}'.format(command.script)
return u'./{}'.format(command.script)
+1 -1
View File
@@ -8,7 +8,7 @@ local_settings = {'command_not_found': '/usr/lib/command-not-found'}
def _get_output(command, settings):
name = command.script.split(' ')[command.script.startswith('sudo')]
check_script = '{} {}'.format(settings.command_not_found, name)
check_script = u'{} {}'.format(settings.command_not_found, name)
result = Popen(check_script, shell=True, stderr=PIPE)
return result.stderr.read().decode('utf-8')
+7 -6
View File
@@ -3,11 +3,12 @@
# 2) is interpreted as shell script
def match(command, settings):
toks = command.script.split()
return (len(toks) > 0
and toks[0].endswith('.py')
and ('Permission denied' in command.stderr or
'command not found' in command.stderr))
toks = command.script.split()
return (len(toks) > 0
and toks[0].endswith('.py')
and ('Permission denied' in command.stderr or
'command not found' in command.stderr))
def get_new_command(command, settings):
return 'python ' + command.script
return 'python ' + command.script
+1 -1
View File
@@ -14,4 +14,4 @@ def match(command, settings):
def get_new_command(command, settings):
return 'sudo {}'.format(command.script)
return u'sudo {}'.format(command.script)