Skip to content

Commit

Permalink
Removed some unnecessary encoding/decoding and normalized newlines.
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-ramadas committed May 7, 2014
1 parent a24bc8e commit 284c2c9
Showing 1 changed file with 6 additions and 6 deletions.
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+')

This comment has been minimized.

Copy link
@rahul-ramadas

rahul-ramadas May 7, 2014

Author Owner

Probably needs to be fixed. This is leaving temporary files hanging around in the OS-specific temp directory. Not that big a deal...

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

1 comment on commit 284c2c9

@rahul-ramadas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes misfo#60

Please sign in to comment.