@Override public String loadChecksum(final Location source) throws IOException { final File cachedChecksum = cachedChecksum(source); if (!cachedChecksum.exists()) return null; return DigestUtils.string(FileUtils.readFile(cachedChecksum)); }
@Override public String loadChecksum(final Location source) throws IOException { final File cachedChecksum = cachedChecksum(source); if (!cachedChecksum.exists()) return null; return DigestUtils.string(FileUtils.readFile(cachedChecksum)); }
@Override public String getVersion() { final File file = new File(path); if (!file.exists()) return null; // no version for non-existent script try { return DigestUtils.bestHex(FileUtils.readFile(file)); } catch (final IOException exc) { log.error(exc); } final Date lastModified = FileUtils.getModifiedTime(file); final String datestamp = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(lastModified); return datestamp; }
@Override public String getVersion() { final File file = new File(path); if (!file.exists()) return null; // no version for non-existent script try { return DigestUtils.bestHex(FileUtils.readFile(file)); } catch (final IOException exc) { log.error(exc); } final Date lastModified = FileUtils.getModifiedTime(file); final String datestamp = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(lastModified); return datestamp; }
private void parsePosition(final Metadata meta, final int posIndex) throws IOException, FormatException { final Position p = meta.getPositions().get(posIndex); final byte[] bytes = FileUtils.readFile(new File(p.metadataFile)); final String s = DigestUtils.string(bytes); parsePosition(s, meta, posIndex); buildTIFFList(meta, posIndex); }
private void parsePosition(final Metadata meta, final int posIndex) throws IOException, FormatException { final Position p = meta.getPositions().get(posIndex); final byte[] bytes = FileUtils.readFile(new File(p.metadataFile)); final String s = DigestUtils.string(bytes); parsePosition(s, meta, posIndex); buildTIFFList(meta, posIndex); }
/** Parse metadata values from the Acqusition.xml file. */ private void parseXMLFile(final Metadata meta, final int imageIndex) throws IOException { final Position p = meta.getPositions().get(imageIndex); final byte[] bytes = FileUtils.readFile(new File(p.xmlFile)); String xmlData = DigestUtils.string(bytes); xmlData = xmlService.sanitizeXML(xmlData); final DefaultHandler handler = new MicromanagerHandler(); xmlService.parseXML(xmlData, handler); }
/** Parse metadata values from the Acqusition.xml file. */ private void parseXMLFile(final Metadata meta, final int imageIndex) throws IOException { final Position p = meta.getPositions().get(imageIndex); final byte[] bytes = FileUtils.readFile(new File(p.xmlFile)); String xmlData = DigestUtils.string(bytes); xmlData = xmlService.sanitizeXML(xmlData); final DefaultHandler handler = new MicromanagerHandler(); xmlService.parseXML(xmlData, handler); }
@Test public void testDownload() throws IOException, InterruptedException, ExecutionException { final byte[] data = randomBytes(0xbabebabe); final String prefix = getClass().getName(); final File inFile = File.createTempFile(prefix, "testDownloadIn"); final File outFile = File.createTempFile(prefix, "testDownloadOut"); try { FileUtils.writeFile(inFile, data); final Location src = new FileLocation(inFile); final Location dest = new FileLocation(outFile); final Download download = downloadService.download(src, dest); download.task().waitFor(); final byte[] result = FileUtils.readFile(outFile); assertArrayEquals(data, result); } finally { inFile.delete(); outFile.delete(); } }
@Test public void testReadmesExample() throws Exception { // extract the example script final File readme = new File("README.md"); final String contents = new String(FileUtils.readFile(readme), "UTF-8"); final String telltale = String.format("```python%n"); final int begin = contents.indexOf(telltale) + telltale.length(); assertTrue(begin > telltale.length()); assertTrue(contents.indexOf(telltale, begin) < 0); final int end = contents.indexOf(String.format("```%n"), begin); assertTrue(end > 0); final String snippet = contents.substring(begin, end); assertTrue(snippet.startsWith("# @ImageJ ij")); final Context context = new Context(); final ScriptService script = context.getService(ScriptService.class); // create mock ImageJ gateway script.addAlias("ImageJ", Mock.class); final ScriptModule module = script.run("op-example.py", snippet, true).get(); assertNotNull(module); module.run(); final Mock ij = context.getService(Mock.class); assertEquals(3, ij.images.size()); assertEquals(11.906, ij.getPixel("sinusoid", 50, 50), 1e-3); assertEquals(100, ij.getPixel("gradient", 50, 50), 1e-3); assertEquals(111.906, ij.getPixel("composite", 50, 50), 1e-3); }
final byte[] cachedData = FileUtils.readFile(cachedFile.getFile()); assertArrayEquals(data, cachedData);