py3 issues
will-moore opened this issue · comments
Batch_ROI_Export failing because of unicode um characters at
File "./script", line 335, in run_script
result = batch_roi_export(conn, script_params)
File "./script", line 280, in batch_roi_export
file_ann = write_csv(conn, export_data, script_params, symbol)
File "./script", line 238, in write_csv
csv_file.write("\n".join(csv_rows))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb5' in position 64: ordinal not in range(128)
Populate_Metadata.py - opening script dialog gives:
omero.ValidationException: exception ::omero::ValidationException
{
serverStackTrace =
serverExceptionClass =
message = Can't find params for 266058!
No stdout.
stderr is in file 266442:
---------------------------------
Traceback (most recent call last):
File "./script", line 43, in <module>
from omero_metadata.populate import ParsingContext
File "/opt/omero/server/venv3/lib64/python3.6/site-packages/omero_metadata/populate.py", line 87
Report bugs to ome-devel@lists.openmicroscopy.org.uk""" % (error, cmd, cmd)
^
SyntaxError: invalid syntax
From the former issue it looks like we need to specify utf-8
encoding wherever appropriate similarly to ome/omero-py#110. Looking at https://python-future.org/compatible_idioms.html#file-io-with-open, it might be possible to have a unified Py2/Py3 idiom:
from io import open
...
with open(file_name, 'w', encoding='utf-8') as csv_file:
...
The latter issue is related to the fact the omero-metadata
plugins needs to be upgraded to Python 3 - see in-progress work in ome/omero-metadata#36
There was a workaround in d9119de to only write encoded bytes to csv, because writing unicode to csv fails on the py3-ci server due to lack of UTF-8 encoding as described ome/omero-figure#343 (comment) and ome/omero-figure#351 (comment)