Created
May 20, 2016 16:37
-
-
Save joshmoore/1e7ae1e181f9e595b12681f3c8788e43 to your computer and use it in GitHub Desktop.
OMERO to_paths.py
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
#!/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