Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed some unnecessary encoding/decoding and normalized newlines. #61

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions shell_turtlestein.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ def run_cmd(cwd, cmd, wait, input_str=None):
shell=shell,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=(subprocess.PIPE if input_str else None))
encoded_input = None if input_str == None else input_str.encode('utf8')
output, error = proc.communicate(encoded_input)
stdin=(subprocess.PIPE if input_str else None),
universal_newlines=True)
output, error = proc.communicate(input_str)
return_code = proc.poll()
if return_code:
show_in_output_panel("`%s` exited with a status code of %s\n\n%s"
% (cmd, return_code, error))
return (False, None)
else:
return (True, output.decode('utf8'))
return (True, output)
else:
subprocess.Popen(cmd, cwd=cwd, shell=shell)
return (False, None)
Expand Down Expand Up @@ -153,8 +153,8 @@ def on_done(self, cwd, cmd_str):
# Since Sublime's build system doesn't support piping to STDIN
# directly, use a tempfile.
text = "".join([active_view.substr(r) for r in input_regions])
temp = tempfile.NamedTemporaryFile(delete=False)
temp.write(text.encode('utf8'))
temp = tempfile.NamedTemporaryFile(delete=False, mode='w+')
temp.write(text)
shell_cmd = "%s < %s" % (shell_cmd, pipes.quote(temp.name))
exec_args = settings['exec_args']
exec_args.update({'cmd': shell_cmd, 'shell': True, 'working_dir': cwd})
Expand Down