Skip to content

Instantly share code, notes, and snippets.

@joshmoore
Created May 20, 2016 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmoore/1e7ae1e181f9e595b12681f3c8788e43 to your computer and use it in GitHub Desktop.
Save joshmoore/1e7ae1e181f9e595b12681f3c8788e43 to your computer and use it in GitHub Desktop.
OMERO to_paths.py
#!/usr/bin/env python
from os.path import exists
import os
import sys
import fileinput
DIST = "/opt/omero/omero/OMERO-CURRENT/lib/python"
DIST = os.environ.get("OMERO_DIST", DIST)
DATA = "/opt/omero-data/OMERO"
DATA = os.environ.get("OMERO_DATA", DATA)
TYPE = "Pixels"
TYPE = os.environ.get("OMERO_TYPE", TYPE)
sys.path.insert(0, DIST)
from omero.util import long_to_path
from path import path
def to_path(pid):
pathname = long_to_path(long(pid))
fullpath = "/".join([DATA, TYPE, pathname])
return path(fullpath)
for line in fileinput.input():
line = line.strip()
pid, hash = line.split()
if len(hash) == 40:
p = to_path(pid)
print "%s %s" % (hash, p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment