Skip to content

Commit

Permalink
Merge pull request #3833 from will-moore/unicode_scripts_12571
Browse files Browse the repository at this point in the history
Unicode scripts 12571
  • Loading branch information
joshmoore committed May 26, 2015
2 parents ad78029 + 9030126 commit d12d29a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Expand Up @@ -874,8 +874,8 @@ def createTagAnnotations(self, tag, desc, oids, well_index=0,
pass
if ann is None:
ann = omero.model.TagAnnotationI()
ann.textValue = rstring(str(tag))
ann.setDescription(rstring(str(desc)))
ann.textValue = rstring(tag.encode('utf8'))
ann.setDescription(rstring(desc.encode('utf8')))
ann = self.conn.saveAndReturnObject(ann)
if tag_group_id: # Put new tag in given tag set
tag_group = None
Expand Down
17 changes: 11 additions & 6 deletions components/tools/OmeroWeb/omeroweb/webclient/views.py
Expand Up @@ -3850,9 +3850,9 @@ def script_run(request, scriptId, conn=None, **kwargs):
# the key and value don't have any data-type defined by
# scripts - just use string
k = str(request.POST[keyName])
v = str(request.POST[valueName])
v = request.POST[valueName]
if len(k) > 0 and len(v) > 0:
paramMap[str(k)] = str(v)
paramMap[str(k)] = v.encode('utf8')
row += 1
keyName = "%s_key%d" % (key, row)
valueName = "%s_value%d" % (key, row)
Expand All @@ -3871,7 +3871,7 @@ def script_run(request, scriptId, conn=None, **kwargs):
values = values[0].split(",")

# try to determine 'type' of values in our list
listClass = omero.rtypes.rstring
listClass = omero.rtypes.RStringI
l = prototype.val # list
# check if a value type has been set (first item of prototype
# list)
Expand All @@ -3886,8 +3886,8 @@ def script_run(request, scriptId, conn=None, **kwargs):
valueList = []
for v in values:
try:
# convert unicode -> string
obj = listClass(str(v.strip()))
# RStringI() will encode any unicode
obj = listClass(v.strip())
except:
logger.debug("Invalid entry for '%s' : %s" % (key, v))
continue
Expand Down Expand Up @@ -3923,7 +3923,12 @@ def script_run(request, scriptId, conn=None, **kwargs):
# if inputMap values not as expected or firstObj is None
conn.SERVICE_OPTS.setOmeroGroup(gid)

logger.debug("Running script %s with params %s" % (scriptName, inputMap))
try:
# Try/except in case inputs are not serializable, e.g. unicode
logger.debug("Running script %s with "
"params %s" % (scriptName, inputMap))
except:
pass
rsp = run_script(request, conn, sId, inputMap, scriptName)
return HttpJsonResponse(rsp)

Expand Down
4 changes: 3 additions & 1 deletion components/tools/OmeroWeb/omeroweb/webgateway/views.py
Expand Up @@ -863,11 +863,13 @@ def render_image(request, iid, z=None, t=None, conn=None, **kwargs):
# don't seem to need to do this for tiff
elif format == 'tif':
rsp = HttpResponse(jpeg_data, content_type='image/tif')
fileName = img.getName().decode('utf8').replace(" ", "_")
fileName = fileName.replace(",", ".")
rsp['Content-Type'] = 'application/force-download'
rsp['Content-Length'] = len(jpeg_data)
rsp['Content-Disposition'] = (
'attachment; filename=%s.%s'
% (img.getName().replace(" ", "_"), format))
% (fileName, format))
return rsp


Expand Down

0 comments on commit d12d29a

Please sign in to comment.