Page 2 of 2

Re: download/save OMERO.table file from remote/to local serv

PostPosted: Sun Feb 26, 2012 8:17 pm
by bhcho
the result is the query result by
Code: Select all
result = conn.getQueryService().findByQuery(query_string,params.page(0,1))


In this case, is the 'result' an OriginalFile (or not)?
I thought this is not the OriginalFile itself. and that's why I did the following
Code: Select all
fid = result.getId().getValue()
file_remote = conn_remote.getObject("OriginalFile", fid)

Am I correct?

BK

--------------------------------------------------
further question.
I got the following error.
Code: Select all
In [146]: fid = result.getId().getValue()     

In [147]: file_remote = conn_remote.getObject("OriginalFile", fid)

In [148]: conn_remote.c.download(file_remote , filename=FNAME_path)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
xxxxxx/lib/python/omero/clients.pyc in download(self, ofile, filename, block_size, filehandle)
    655             if not ofile or not ofile.id:
    656                 raise omero.ClientError("No file to download")
--> 657             ofile = self.__sf.getQueryService().get("OriginalFile", ofile.id.val)
    658
    659             if block_size > ofile.size.val:

AttributeError: 'long' object has no attribute 'val'


Any suggestion?

Best,
BK

Re: download/save OMERO.table file from remote/to local serv

PostPosted: Mon Feb 27, 2012 8:42 am
by jmoore
bhcho wrote:In this case, is the 'result' an OriginalFile (or not)?


What's your query string? Assuming it's returning an original file, then yes.

I thought this is not the OriginalFile itself. and that's why I did the following
Code: Select all
fid = result.getId().getValue()
file_remote = conn_remote.getObject("OriginalFile", fid)

Am I correct?


If your query is returning an original file, then these two lines are just reloading the object, and therefore, unnecessary.

further question.
I got the following error.
Code: Select all
In [146]: fid = result.getId().getValue()     

In [147]: file_remote = conn_remote.getObject("OriginalFile", fid)

In [148]: conn_remote.c.download(file_remote , filename=FNAME_path)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
xxxxxx/lib/python/omero/clients.pyc in download(self, ofile, filename, block_size, filehandle)
    655             if not ofile or not ofile.id:
    656                 raise omero.ClientError("No file to download")
--> 657             ofile = self.__sf.getQueryService().get("OriginalFile", ofile.id.val)
    658
    659             if block_size > ofile.size.val:

AttributeError: 'long' object has no attribute 'val'


Any suggestion?


Ah, yes. I filed this under [url=https://trac.openmicroscopy.org.uk/ome/ticket/8143]ticket 8143. This is caused by getting the object from conn and then passing it to conn.c. Sorry about that. To workaround, pass file_remote._obj to the download method, i.e.
Code: Select all
conn_remote.c.download(file_remote._obj , filename=FNAME_path)


Cheers,
~Josh