Search in sources :

Example 1 with FileManager

use of maspack.fileutil.FileManager in project artisynth_core by artisynth.

the class LibraryInstaller method verifyJars.

public boolean verifyJars(boolean updateLibs) throws Exception {
    boolean allOK = true;
    if (myJarnames.size() > 0) {
        FileManager grabber = new FileManager();
        grabber.setVerbosityLevel(LogLevel.ALL);
        FileTransferListener listener = new DefaultConsoleFileTransferListener();
        grabber.addTransferListener(listener);
        // 100ms
        grabber.getTransferMonitor().setPollSleep(100);
        grabber.setDownloadDir(myLibDir);
        grabber.setRemoteSource(myRemoteSource);
        int options = (updateLibs ? FileManager.CHECK_HASH : 0);
        for (String jarname : myJarnames) {
            File jfile = new File(myLibDir, jarname);
            if (!jfile.exists()) {
                try {
                    grabber.getRemote(jarname);
                    System.out.println("Downloaded jar file " + jfile);
                } catch (Exception e) {
                    if (isConnectionException(e)) {
                        throw e;
                    }
                    System.out.println("Failed to download jar file " + jfile + ":");
                    System.out.println(e.getMessage());
                    allOK = false;
                }
            } else if (updateLibs) {
                try {
                    if (!grabber.equalsHash(jarname)) {
                        grabber.getRemote(jarname);
                    }
                    System.out.println("Updated jar file " + jfile);
                } catch (Exception e) {
                    if (isConnectionException(e)) {
                        throw e;
                    }
                    System.out.println("Failed to update jar file " + jfile + ":");
                    System.out.println(e.getMessage());
                }
            }
        }
    }
    return allOK;
}
Also used : DefaultConsoleFileTransferListener(maspack.fileutil.DefaultConsoleFileTransferListener) FileTransferListener(maspack.fileutil.FileTransferListener) File(java.io.File) FileManager(maspack.fileutil.FileManager) IOException(java.io.IOException) URIxSyntaxException(maspack.fileutil.uri.URIxSyntaxException) DefaultConsoleFileTransferListener(maspack.fileutil.DefaultConsoleFileTransferListener)

Example 2 with FileManager

use of maspack.fileutil.FileManager in project artisynth_core by artisynth.

the class DicomTest method build.

public void build(String[] args) throws IOException {
    // download the BRAINIX dicom data if it does not already exist
    String localDir = ArtisynthPath.getSrcRelativePath(this, "data/MONO2_HEART");
    FileManager fileManager = new FileManager(localDir, "gz:" + dicom_url + "!/");
    fileManager.setConsoleProgressPrinting(true);
    // download zip file first
    fileManager.setOptions(FileManager.DOWNLOAD_ZIP);
    // extract
    File dicomPath = fileManager.get(dicom_file);
    DicomViewer dcp = new DicomViewer("Heart", dicomPath.getAbsolutePath(), null, /*check subdirectories*/
    false);
    addRenderable(dcp);
}
Also used : DicomViewer(artisynth.core.renderables.DicomViewer) File(java.io.File) FileManager(maspack.fileutil.FileManager)

Aggregations

File (java.io.File)2 FileManager (maspack.fileutil.FileManager)2 DicomViewer (artisynth.core.renderables.DicomViewer)1 IOException (java.io.IOException)1 DefaultConsoleFileTransferListener (maspack.fileutil.DefaultConsoleFileTransferListener)1 FileTransferListener (maspack.fileutil.FileTransferListener)1 URIxSyntaxException (maspack.fileutil.uri.URIxSyntaxException)1