[ome-devel] ometiff download toubles

Wood, Christopher CJW at stowers.org
Thu Feb 24 15:14:39 GMT 2011


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