Skip to content

Instantly share code, notes, and snippets.

@sbesson
Last active September 13, 2017 15:19
Show Gist options
  • Save sbesson/e2d78a7825248e3f73cf to your computer and use it in GitHub Desktop.
Save sbesson/e2d78a7825248e3f73cf to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# Script to update Bio-Formats server-side
import urllib2
import os
import shutil
DONWLOADS_URL = "http://downloads.openmicroscopy.org/bio-formats"
RELEASE = "5.1.4"
JARS = [
"formats-api.jar",
"formats-bsd.jar",
"formats-common.jar",
"formats-gpl.jar",
"jai_imageio.jar",
"lwf-stubs.jar",
"mdbtools-java.jar",
"metakit.jar",
"ome-poi.jar",
"ome-xml.jar",
"specification.jar",
"turbojpeg.jar"]
artifact_url = DONWLOADS_URL + '/' + RELEASE + '/artifacts/'
server_dir = os.path.realpath("lib/server")
client_dir = os.path.realpath("lib/client")
backup_dir = os.path.realpath("lib/backup")
if not os.path.exists(backup_dir):
os.makedirs(backup_dir)
for jar in JARS:
# Backing up
server_jar = os.path.join(server_dir, jar)
client_jar = os.path.join(client_dir, jar)
backup_jar = os.path.join(backup_dir, jar)
print 'backing up %s to %s' % (server_jar, backup_jar)
shutil.copyfile(server_jar, backup_jar)
jar_url = artifact_url + jar
print "Downloading %s" % jar_url
f = urllib2.urlopen(jar_url)
data = f.read()
with open(server_jar, "wb") as f:
print "Copying to %s" % server_jar
f.write(data)
with open(client_jar, "wb") as f:
print "Copying to %s" % client_jar
f.write(data)
@sbesson
Copy link
Author

sbesson commented Sep 13, 2017

Coming back to this a year later. See https://github.com/sbesson/bio-formats-omero for an experimental solution (inspired by https://github.com/openmicroscopy/bio-formats-fiji).

The advantage of using Maven is the dependency management i.e. partly addressing/delegating the idempotency, catalog and checksum questions above.

Main drawbacks as mentioned in the README is this approach is currently based on the Bio-Formats POM rather than the OMERO POM. Thus:

  • conflict/exclusions managed at the OMERO level are not handled (dependencies defined in BF trump)
  • since only a subset of the dependencies are copied, the target is additive only and does not handle deletion/renaming etc

If this turns out to be useful, a way to resolve the above might be to base the pom.xml on https://github.com/ome/pom-omero-client, clean lib/server and lib/client in the clean phase and copy blitz and the overriden Bio-Formats dependencies in the package phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment