Search in sources :

Example 1 with FileTransferListener

use of maspack.fileutil.FileTransferListener 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 FileTransferListener

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

the class ArtisynthWebGrabber method addListener.

private void addListener() {
    FileTransferListener listener = new DefaultConsoleFileTransferListener();
    addTransferListener(listener);
}
Also used : FileTransferListener(maspack.fileutil.FileTransferListener) DefaultConsoleFileTransferListener(maspack.fileutil.DefaultConsoleFileTransferListener) DefaultConsoleFileTransferListener(maspack.fileutil.DefaultConsoleFileTransferListener)

Aggregations

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