Created
September 27, 2012 07:57
-
-
Save chris-allan/3792781 to your computer and use it in GitHub Desktop.
OMERO pyramid checking script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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