Repository: galaxyproject/planemo
Issue: planemo tool_init --help_from_command bytes under Python 3

Example using planemo installed under conda using Python 3.6.3:

```
$ planemo --version
planemo, version 0.47.0
$ planemo tool_init -i head -n head --help_from_command "head --help"
Tool written to head.xml
$ more head.xml 
<tool id="head" name="head" version="0.1.0">
    <requirements>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
        TODO: Fill in command template.
    ]]></command>
    <inputs>
    </inputs>
    <outputs>
    </outputs>
    <help><![CDATA[
        b"Usage: head [OPTION]... [FILE]...\\nPrint the first 10 lines of each FILE to standard output.\\nWith more t
han one FILE, precede each with a header giving the file name.\\nWith no FILE, or when FILE is -, read standard inpu
t.\\n\\nMandatory arguments to long options are mandatory for short options too.\\n  -c, --bytes=[-]K         print th
e first K bytes of each file;\\n                             with the leading '-', print all but the last\\n         
                    K bytes of each file\\n  -n, --lines=[-]K         print the first K lines instead of the first 1
0;\\n                             with the leading '-', print all but the last\\n                             K lines
 of each file\\n  -q, --quiet, --silent    never print headers giving file names\\n  -v, --verbose            always 
print headers giving file names\\n      --help     display this help and exit\\n      --version  output version infor
mation and exit\\n\\nK may have a multiplier suffix:\\nb 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\\nGB 1000*100
0*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\\n\\nGNU coreutils online help: <http://www.gnu.org/software/c
oreutils/>\\nFor complete documentation, run: info coreutils 'head invocation'\\n"
    ]]></help>
    <citations>
    </citations>
</tool>
```

Notice the help text was captured as a bytes string, and presented as such in the XML output (``b"Usage: ...``)

I have not delved into the code base to see how other bytes-string/unicode issues have been dealt with in planemo for stdout/stderr from command line tools.

Changed files:
planemo/tool_builder.py, planemo/git.py

diff --git a/planemo/git.py b/planemo/git.py
index d14ffd3d..ffdc73ca 100644
--- a/planemo/git.py
+++ b/planemo/git.py
@@ -77,7 +77,9 @@ def diff(ctx, directory, range):
     cmd_template = "cd '%s' && git diff --name-only '%s' --"
     cmd = cmd_template % (directory, range)
     stdout, _ = io.communicate(
-        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
+        cmd,
+        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+        universal_newlines=True
     )
     return [l.strip() for l in text_type(stdout).splitlines() if l]
 
diff --git a/planemo/tool_builder.py b/planemo/tool_builder.py
index c063cb6c..a1d81870 100644
--- a/planemo/tool_builder.py
+++ b/planemo/tool_builder.py
@@ -608,7 +608,8 @@ def _handle_help(kwds):
                 help_from_command,
                 shell=True,
                 stdout=subprocess.PIPE,
-                stderr=subprocess.STDOUT
+                stderr=subprocess.STDOUT,
+                universal_newlines=True
             )
             help_text = p.communicate()[0]