This should fix https://github.com/galaxyproject/galaxy/issues/9356
The bug itself was due to not calling toolbox._load_tool_panel()
after injecting the default shed_tool_config_file into the toolbox,
but implentation-wise it seems better to have this logic inside
the toolbox.
If not using the largely undocumented and debug-y `integrated_tool_panel_tracking_directory`
we should use RenamedTemporaryFile which creates a temp file in the
directory where `integrated_tool_panel_file` lives, and upon succesful
write rename the file to `integrated_tool_panel_file`.
We use this in other places in the code and it seems to work well
when multiple threads are potentially modifying the target file.
Fixes
```
Traceback (most recent call last):
File "/Users/mvandenb/.pyenv/versions/3.6.9/bin/planemo", line 11, in <module>
load_entry_point('planemo', 'console_scripts', 'planemo')()
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/mvandenb/src/planemo/planemo/cli.py", line 190, in handle_blended_options
return f(*args, **kwds)
File "/Users/mvandenb/src/planemo/planemo/commands/cmd_lint.py", line 58, in cli
recursive=kwds["recursive"]
File "/Users/mvandenb/src/planemo/planemo/tool_lint.py", line 33, in lint_tools_on_path
if not lint_tool_source(tool_xml, name=basename(tool_path), **lint_args):
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/galaxy/tool_util/lint.py", line 18, in lint_tool_source
lint_tool_source_with(lint_context, tool_source, extra_modules)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/galaxy/tool_util/lint.py", line 54, in lint_tool_source_with
lint_context.lint(name, value, tool_source)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/galaxy/tool_util/lint.py", line 83, in lint
lint_func(lint_target, self)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/galaxy/tool_util/linters/general.py", line 27, in lint_general
parsed_version = packaging.version.parse(version)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/packaging/version.py", line 28, in parse
return Version(version)
File "/Users/mvandenb/.pyenv/versions/3.6.9/lib/python3.6/site-packages/packaging/version.py", line 219, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
```
Fixes
```
File "..\planemo\venv\lib\site-packages\galaxy\tool_util\loader_directory.py", line 174, in looks_like_xml
start_contents = f.read(5 * 1024)
File "..\planemo\venv\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1713: character maps to <undefined>
```
Still weird that this is cp1252 though.