/docker-compose.yml Secret
Created
November 10, 2017 07:56
-
-
Save joshmoore/0c2e5319d8d5ae7f79ee82e3e68b721b to your computer and use it in GitHub Desktop.
A script to demonstrate an error when attempting to export an image file to a remote OMOERO server.
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
version: '3' | |
services: | |
db1: | |
image: postgres | |
environment: | |
- POSTGRES_PASSWORD=postgres | |
db2: | |
image: postgres | |
environment: | |
- POSTGRES_PASSWORD=postgres | |
omero1: | |
image: openmicroscopy/omero-server:5.4 | |
environment: | |
- CONFIG_omero_db_host=db1 | |
- CONFIG_omero_db_user=postgres | |
- CONFIG_omero_db_name=postgres | |
- CONFIG_omero_db_pass=postgres | |
- ROOTPASS=omero | |
links: | |
- omero2:omero2 | |
volumes: | |
- ".:/gist" | |
omero2: | |
image: openmicroscopy/omero-server:5.4 | |
environment: | |
- CONFIG_omero_db_host=db2 | |
- CONFIG_omero_db_user=postgres | |
- CONFIG_omero_db_name=postgres | |
- CONFIG_omero_db_pass=postgres | |
- ROOTPASS=omero |
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
# From e-mail: http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2017-October/004076.html | |
# We upload and run an OMERO.script | |
# that can connect to another remote OMERO server. | |
from omero.gateway import BlitzGateway | |
import omero | |
USERNAME = "root" | |
PASSWORD = "omero" | |
REMOTE_SERVER = "omero2" | |
REMOTE_USER = "root" | |
REMOTE_PASS = "omero" | |
FILE_LOCATION = "/tmp/foo.fake" | |
OMERO_SERVER = "/opt/omero/server/OMERO.server" | |
# First test if we can connect directly to remote server... | |
# If yes, this session will be used as an argument to the | |
# script | |
c = omero.client(host=REMOTE_SERVER, port=4064) | |
sf = c.createSession(REMOTE_USER, REMOTE_PASS) | |
k = c.getSessionId() | |
print c, sf | |
# Upload script and try to connect | |
SCRIPT = """ | |
import os | |
import omero | |
import omero.cli | |
import omero.scripts as scripts | |
from omero.gateway import BlitzGateway | |
from path import path | |
import sys | |
import subprocess | |
remote_server = '%s' | |
remote_user = '%s' | |
file_loc = '%s' | |
omero_dist = '%s' | |
client = scripts.client("export_remote", scripts.String("Session_Key")) | |
params = client.getInputs(unwrap=True) | |
c = omero.client(host=remote_server, port=4064, args=["--Ice.Config=/dev/null", "--omero.debug=1"]) | |
k = params["Session_Key"] | |
c.joinSession(k) | |
print "Joined", k, "on", remote_server | |
# View information | |
conn = BlitzGateway(client_obj=c) | |
for p in conn.getObjects("Project"): | |
print p.id, p.name | |
print "Connected, now to transfer image" | |
cli = omero.cli.CLI() | |
cli.loadplugins() | |
cli.set_client(c) | |
del os.environ["ICE_CONFIG"] | |
cli.invoke(["import", file_loc]) | |
""" % (REMOTE_SERVER, REMOTE_USER, FILE_LOCATION, OMERO_SERVER) | |
conn = BlitzGateway(USERNAME, PASSWORD, host="localhost", port=4064) | |
conn.connect() | |
script_service = conn.getScriptService() | |
sessionId = conn._getSessionId() | |
script_id = script_service.getScriptID("export_to_server.py") | |
if script_id < 0: | |
script_id = script_service.uploadOfficialScript("export_to_server.py", SCRIPT) | |
# TODO: This should still take the filename as a parameter to be complete. | |
# Note, however, that that opens a security in your server. You should check | |
# for valid paths before enabling such a script on your server. | |
proc = script_service.runScript(script_id, {"Session_Key": omero.rtypes.rstring(k)}, None) | |
job = proc.getJob() | |
cb = omero.scripts.ProcessCallbackI(conn.c, proc) | |
try: | |
print "Job %s ready" % job.id.val | |
print "Waiting...." | |
while proc.poll() is None: | |
cb.block(1000) | |
print "Callback received: %s" % cb.block(0) | |
rv = proc.getResults(3) | |
finally: | |
cb.close() | |
# print rv | |
if rv.get('stderr'): | |
print "Error. See file: ", rv.get('stderr').getValue().id.val | |
if rv.get('stdout'): | |
print "Std out. See file: ", rv.get('stdout').getValue().id.val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment