We're Hiring!

download/save OMERO.table file from remote/to local server

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

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

Postby bhcho » Sun Feb 26, 2012 8:17 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

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

Postby jmoore » Mon Feb 27, 2012 8:42 am

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Previous

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests