Skip to content

Instantly share code, notes, and snippets.

@chris-allan
Created September 27, 2012 07:57
Show Gist options
  • Save chris-allan/3792781 to your computer and use it in GitHub Desktop.
Save chris-allan/3792781 to your computer and use it in GitHub Desktop.
OMERO pyramid checking script
import time
import omero
import omero.clients
from omero.rtypes import unwrap
HOST='localhost'
PORT=4064
USER='root'
PASSWORD='omero'
BACKOFF=15 # seconds
def pyramids(client):
session = client.getSession()
iconfig = session.getConfigService()
width = long(iconfig.getConfigValue('omero.pixeldata.max_plane_width'))
height = long(iconfig.getConfigValue('omero.pixeldata.max_plane_height'))
iquery = session.getQueryService()
params = omero.sys.ParametersI()
params.addLong('width', width)
params.addLong('height', height)
pixels_ids = iquery.projection(
'select id from Pixels as p '
'where (p.sizeX * p.sizeY) > (:width * :height)', params)[0]
rps = session.createRawPixelsStore()
for pixels_id in pixels_ids:
pixels_id = unwrap(pixels_id)
has_pyramid = False
while not has_pyramid:
try:
rps.setPixelsId(pixels_id, False)
has_pyramid = True
except omero.MissingPyramidException:
print 'Pixels:%d missing pyramid, trying in %d secs' % \
(pixels_id, BACKOFF)
time.sleep(BACKOFF)
print 'Pixels:%d has pyramid' % pixels_id
client = omero.client(HOST, PORT)
try:
client.createSession(USER, PASSWORD)
client.enableKeepAlive(60)
pyramids(client)
finally:
client.closeSession()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment