pickle dumps are binary
Fixes https://sentry.galaxyproject.org/sentry/main/issues/503803/:
```
TypeError: write() argument must be str, not bytes
File "galaxy/web/framework/middleware/sentry.py", line 43, in __call__
iterable = self.application(environ, start_response)
File "/cvmfs/main.galaxyproject.org/venv/lib/python3.6/site-packages/paste/recursive.py", line 85, in __call__
return self.application(environ, start_response)
File "galaxy/web/framework/middleware/statsd.py", line 34, in __call__
req = self.application(environ, start_response)
File "/cvmfs/main.galaxyproject.org/venv/lib/python3.6/site-packages/paste/httpexceptions.py", line 640, in __call__
return self.application(environ, start_response)
File "galaxy/web/framework/base.py", line 143, in __call__
return self.handle_request(environ, start_response)
File "galaxy/web/framework/base.py", line 222, in handle_request
body = method(trans, **kwargs)
File "galaxy/webapps/galaxy/controllers/openid.py", line 30, in openid_auth
consumer = self.openid_manager.get_consumer(trans)
File "galaxy/openid/openid_manager.py", line 58, in get_consumer
return consumer.Consumer(self.get_session(trans), self.store)
File "galaxy/openid/openid_manager.py", line 50, in get_session
pickle.dump(dict(), open(session_file, 'w'))
```
Should fix https://sentry.galaxyproject.org/sentry/main/issues/501237/:
```
TypeError: a bytes-like object is required, not 'str'
File "galaxy/datatypes/data.py", line 625, in as_display_type
return getattr(self, self.supported_display_apps[type]['file_function'])(dataset, **kwd)
File "galaxy/datatypes/interval.py", line 446, in as_ucsc_display_file
return Interval.as_ucsc_display_file(self, dataset)
File "galaxy/datatypes/interval.py", line 225, in as_ucsc_display_file
fh.write('%s\n' % '\t'.join(tmp))
File "python3.6/tempfile.py", line 485, in func_wrapper
return func(*args, **kwargs)
```
Fixes:
```
Error - <class 'binascii.Error'>: decoding with 'hex' codec failed (Error: Odd-length string)
URL: http://127.0.0.1:8080/visualization/circster?id=undefined
File '/Users/mvandenb/src/galaxy/lib/galaxy/web/framework/middleware/error.py', line 154 in __call__
app_iter = self.application(environ, sr_checker)
File '/Users/mvandenb/src/galaxy/.venv/lib/python3.6/site-packages/paste/recursive.py', line 85 in __call__
return self.application(environ, start_response)
File '/Users/mvandenb/src/galaxy/.venv/lib/python3.6/site-packages/paste/httpexceptions.py', line 640 in __call__
return self.application(environ, start_response)
File '/Users/mvandenb/src/galaxy/lib/galaxy/web/framework/base.py', line 143 in __call__
return self.handle_request(environ, start_response)
File '/Users/mvandenb/src/galaxy/lib/galaxy/web/framework/base.py', line 222 in handle_request
body = method(trans, **kwargs)
File '/Users/mvandenb/src/galaxy/lib/galaxy/webapps/galaxy/controllers/visualization.py', line 764 in circster
vis = self.get_visualization(trans, id, check_ownership=False, check_accessible=True)
File '/Users/mvandenb/src/galaxy/lib/galaxy/webapps/base/controller.py', line 651 in get_visualization
visualization = trans.sa_session.query(trans.model.Visualization).get(trans.security.decode_id(id))
File '/Users/mvandenb/src/galaxy/lib/galaxy/security/idencoding.py', line 84 in decode_id
return int(unicodify(id_cipher.decrypt(codecs.decode(obj_id, 'hex'))).lstrip("!"))
Error: decoding with 'hex' codec failed (Error: Odd-length string)
```
among other things. This happens when a new circster instance is created
and it doens't have an id yet. `id` then is `undefined`, which is not a
valid id.
Fixes:
```
galaxy.web.framework.decorators ERROR 2020-02-07 11:58:02,554 Uncaught exception in exposed API method:
Traceback (most recent call last):
File "/Users/mvandenb/src/galaxy/lib/galaxy/web/framework/decorators.py", line 157, in decorator
rval = func(self, trans, *args, **kwargs)
File "/Users/mvandenb/src/galaxy/lib/galaxy/webapps/galaxy/api/datasets.py", line 139, in show
rval = self._data(trans, dataset, **kwd)
File "/Users/mvandenb/src/galaxy/lib/galaxy/webapps/galaxy/api/datasets.py", line 289, in _data
return indexer.get_data(chrom, low, high)
File "/Users/mvandenb/src/galaxy/lib/galaxy/visualization/data_providers/genome.py", line 1233, in get_data
result = summarize_region(bbi, chrom, start, end, num_points)
File "/Users/mvandenb/src/galaxy/lib/galaxy/visualization/data_providers/genome.py", line 1196, in summarize_region
for i in range(num_points):
TypeError: 'float' object cannot be interpreted as an integer
```
Fixes
```
Traceback (most recent call last):
File "/Users/mvandenb/src/galaxy/lib/galaxy/web/framework/decorators.py", line 157, in decorator
rval = func(self, trans, *args, **kwargs)
File "/Users/mvandenb/src/galaxy/lib/galaxy/webapps/galaxy/api/datasets.py", line 137, in show
is_true(kwd.get('retry', False)))
File "/Users/mvandenb/src/galaxy/lib/galaxy/webapps/galaxy/api/datasets.py", line 212, in _converted_datasets_state
if not data_provider.has_data(chrom):
File "/Users/mvandenb/src/galaxy/lib/galaxy/visualization/data_providers/genome.py", line 1125, in has_data
f, bbi = self._get_dataset()
File "/Users/mvandenb/src/galaxy/lib/galaxy/visualization/data_providers/genome.py", line 1261, in _get_dataset
return f, BigWigFile(file=f)
File "lib/bx/bbi/bigwig_file.pyx", line 161, in bx.bbi.bigwig_file.BigWigFile.__init__
File "lib/bx/bbi/bbi_file.pyx", line 125, in bx.bbi.bbi_file.BBIFile.__init__
File "lib/bx/bbi/bbi_file.pyx", line 135, in bx.bbi.bbi_file.BBIFile.open
File "/Users/mvandenb/src/galaxy/.venv/lib/python3.6/site-packages/bx/misc/binary_file.py", line 40, in __init__
bytes = file.read(4)
File "/Users/mvandenb/src/galaxy/.venv/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
```
By default it's a bytestring.
Also:
- don't use `shell=True`
- add a `splitlines()` forgotten in commit 670897ec5c
- raise exception instead of returning `error_info` in `docker_to_singularity()`
- use a random temp dir in `singularity_container_test()`
I rarely read entire help texts (shame on me, I know), so I missed the
example below that was quoting when there is a whitespace.
For consistency it's probably better too to qute all parameters.