[ome-devel] ometiff download toubles

Josh Moore josh at glencoesoftware.com
Thu Feb 24 15:33:48 GMT 2011


Hi Chris,

the message "Cannot configure during output" comes from ExporterI.java:

  http://git.openmicroscopy.org/?p=ome.git;a=blob;f=components/blitz/src/ome/services/blitz/impl/ExporterI.java;#l230

and implies that addImage() was called after generateTiff(), but that certainly doesn't look possible from your code snippet. This may be caused by the service wrapper from omero.gateway, but I'll let others speak to that. You might want to try either using the raw service (acquired from the session as opposed to the BlitzGateway), or use the facilities of the gateway, like the exportOmeTiff method:

  http://git.openmicroscopy.org/?p=ome.git;a=blob;f=components/tools/OmeroPy/src/omero/gateway/__init__.py#l5641

Cheers,
~Josh.


On Feb 24, 2011, at 4:14 PM, Wood, Christopher wrote:

> Hi,
> 
> I am trying to write a python script to be able to download an OME-TIFF from omeroweb.  The code below will work, but it only works once. On the second attempt I get the error below the code. On the third attempt, it stops working at omero needs to be restarted.
> 
> I do this same sort of thing for original raw files and I don't have a problem.
> 
> OMERO Beta4.2.2-r8718-Beta4.2-b56
> python 2.4
> 
> Here is the process:
> 1) restart omero and omeroweb
> 2) goto http://chi/websimr/getOMETIFF/3914/
> 3) file downloads as expected
> 4) try the same or different file again, I get the error below
> 5) try again and omero need to be restarted. (Insight stop responding,  webclient stop responding, ....)
> 
> Let me know if you need anything from the log files.
> 
> Thanks,
> Chris
> ====================================================
> def getOMETIFF(request, iid):
> 
>    if conn is None or not conn.isConnected():
>        return HttpResponseRedirect(reverse('websimr_login'))
> 
>    iid = int(iid)
>    image = conn.getImage(iid)
>    name = image.getName()
>    name = name.replace('\\', '/')
>    name = os.path.basename(name)
>    name = os.path.splitext(name)[0] + '.ome.tif'
> 
>    exporter = conn.createExporter()
>    exporter.addImage(iid)            <------------ this line causes problems **********************
>    exporter.generateTiff()
> 
> 
>    tempdir = settings.FILE_UPLOAD_TEMP_DIR
>    v1 = iid
>    v2 = conn._sessionUuid
>    tempname = os.path.join(tempdir,('%i-%s.download' % (v1, v2)))
>    temp = tempname.replace('\\','/')
> 
>    handle = open(temp, 'wb')
>    offset = 0
> 
>    while 1==1:
>        rv = exporter.read(offset, 512*512)
>        if not rv:
>            break
>        offset += len(rv)
>        handle.write(rv)
> 
> 
>    handle.close()
> 
>    ometiff = FileWrapper(file(temp))
>    response = HttpResponse(ometiff)
> 
>    response['Content-Length'] = str(offset)
>    response['Content-Type'] = 'application/force-download'
> 
>    response['Content-Disposition']='attachment;filename=' + name
>    return response
> 
> ====================================================
> this is the debuggingout put from the web page
> ---
> Environment:
> 
> Request Method: GET
> Request URL: http://chi/websimr/getOMETIFF/3914/
> Django Version: 1.1.1
> Python Version: 2.4.3
> Installed Applications:
> ['django.contrib.admin',
> 'django.contrib.markup',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'omeroweb.feedback',
> 'omeroweb.webadmin',
> 'omeroweb.webclient',
> 'omeroweb.webgateway',
> 'omeroweb.webtest',
> 'omeroweb.websimr',
> 'omeroweb.limsweb',
> 'omeroweb.webmobile']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.doc.XViewMiddleware')
> 
> 
> Traceback:
> File "/OMERO/omero_dist/lib/python/django/core/handlers/base.py" in get_response
>  92.                 response = callback(request, *callback_args, **callback_kwargs)
> File "/OMERO/omero_dist/lib/python/omeroweb/websimr/views.py" in getOMETIFF
>  114.     exporter.addImage(iid)
> File "/OMERO/omero_dist/lib/python/omero/gateway/__init__.py" in wrapped
>  2306.             return inner(*args, **kwargs)
> File "/OMERO/omero_dist/lib/python/omero/gateway/__init__.py" in inner
>  2267.             return f(*args, **kwargs)
> File "/OMERO/omero_dist/lib/python/omero_api_Exporter_ice.py" in addImage
>  81.             return _M_omero.api.Exporter._op_addImage.invoke(self, ((id, ), _ctx))
> 
> Exception Type: ApiUsageException at /websimr/getOMETIFF/3914/
> Exception Value: exception ::omero::ApiUsageException
> {
>    serverStackTrace =
>    serverExceptionClass =
>    message = Cannot configure during output
> }
> 



More information about the ome-devel mailing list