Skip to content

Instantly share code, notes, and snippets.

@sbesson
Last active August 29, 2015 14:04
Show Gist options
  • Save sbesson/398859725643a9f6ea95 to your computer and use it in GitHub Desktop.
Save sbesson/398859725643a9f6ea95 to your computer and use it in GitHub Desktop.
A simple CLI script to import a series of format files corresponding to a ticket
#!/bin/bash
set -e
set -u
FILE=$1
shift;
# Define environement variables
HOST=${HOST:-localhost}
PORT=${PORT:-4064}
ROOT_PASSWORD=${ROOT_PASSWORD:-omero}
GROUP=${GROUP:-formats}
FORMAT=${FORMAT:-ome-tiff}
USER_PASSWORD=${USER_PASSWORD:-ome}
TICKET=${TICKET:-1}
# Create group and user (named after format to import)
bin/omero login -s $HOST -p $PORT -u root -w $ROOT_PASSWORD
bin/omero group add $GROUP --ignore-existing
bin/omero user add $FORMAT $FORMAT $FORMAT $GROUP -P ome --ignore-existing
bin/omero logout
# Login as format user
bin/omero login -s $HOST -p $PORT -u $FORMAT -w $USER_PASSWORD
# Create dataset named after ticket number
dataset=$(bin/omero obj new Dataset name="#$TICKET" description="http://trac.openmicroscopy.org/ome/ticket/$TICKET")
# Import the file into the dataset via in-place import (ln_s)
handle() {
bin/omero import -d $dataset -u $FORMAT \
---file $TICKET.out ---errs $TICKET.err "$1" -- \
--transfer=ln_s --checksum_algorithm=File-Size-64
}
while read i; do handle "$i"; done < $FILE
# Logout
bin/omero logout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment