Example usage for java.lang System setOut

List of usage examples for java.lang System setOut

Introduction

In this page you can find the example usage for java.lang System setOut.

Prototype

public static void setOut(PrintStream out) 

Source Link

Document

Reassigns the "standard" output stream.

Usage

From source file:fr.gouv.culture.vitam.droid.DroidHandler.java

/**
 * Check one file// w ww .j  a  v  a 2  s .c  o m
 * 
 * @param file
 * @param argument
 * @return a List of DroidFileFOrmat
 * @throws CommandExecutionException
 */
public List<DroidFileFormat> checkFileFormat(File file, VitamArgument argument)
        throws CommandExecutionException {
    Collection<File> matchedFiles = new ArrayList<File>(1);

    String path = file.getAbsolutePath();
    String slash = path.contains(FORWARD_SLASH) ? FORWARD_SLASH : BACKWARD_SLASH;
    String slash1 = slash;

    matchedFiles.add(file);
    path = "";
    ResultPrinter resultPrinter = new ResultPrinter(vitamBinarySignatureIdentifier,
            containerSignatureDefinitions, path, slash, slash1, argument.archive, argument.checkSubFormat);

    // change System.out
    PrintStream oldOut = System.out;
    DroidFileFormatOutputStream out = new DroidFileFormatOutputStream(
            vitamBinarySignatureIdentifier.getSigFile(), argument);
    PrintStream newOut = new PrintStream(out, true);
    try {
        System.setOut(newOut);
        realCheck(file, resultPrinter);
    } finally {
        // reset System.out
        System.setOut(oldOut);
        newOut.close();
        newOut = null;
    }
    return out.getResult();
}

From source file:mil.dod.th.ose.junit4xmltestrunner.ant.XMLJUnitResultFormatter.java

public void cleanup() {
    System.setOut(m_OldStdOut);
    System.setErr(m_OldStdErr);
}

From source file:org.apache.easyant.core.EasyAntMain.java

/**
 * Process command line arguments. When ant is started from Launcher, launcher-only arguments do not get passed
 * through to this routine./*from  www  . j a  va 2  s  .  com*/
 *
 * @since Ant 1.6
 */
private void processArgs(CommandLine line) {
    String searchForThis;
    PrintStream logTo = null;

    if (line.hasOption("help")) {
        printUsage();
        return;
    }
    if (easyAntConfiguration.getMsgOutputLevel() >= Project.MSG_VERBOSE || line.hasOption("version")) {
        printVersion();
        if (line.hasOption("version")) {
            return;
        }
    }
    if (line.hasOption("showMemoryDetails")) {
        easyAntConfiguration.setShowMemoryDetails(true);
    }
    if (line.hasOption("diagnostics")) {
        Diagnostics.doReport(System.out, easyAntConfiguration.getMsgOutputLevel());
        return;
    }
    if (line.hasOption("quiet")) {
        easyAntConfiguration.setMsgOutputLevel(Project.MSG_WARN);
    }
    if (line.hasOption("verbose")) {
        easyAntConfiguration.setMsgOutputLevel(Project.MSG_VERBOSE);
    }
    if (line.hasOption("debug")) {
        easyAntConfiguration.setMsgOutputLevel(Project.MSG_DEBUG);
    }
    if (line.hasOption("noinput")) {
        easyAntConfiguration.setAllowInput(false);
    }
    if (line.hasOption("logfile")) {
        try {
            File logFile = new File(line.getOptionValue("logfile"));
            logTo = new PrintStream(new FileOutputStream(logFile));
            isLogFileUsed = true;
        } catch (IOException ioe) {
            String msg = "Cannot write on the specified log file. "
                    + "Make sure the path exists and you have write " + "permissions.";
            throw new BuildException(msg);
        } catch (ArrayIndexOutOfBoundsException aioobe) {
            String msg = "You must specify a log file when " + "using the -log argument";
            throw new BuildException(msg);
        }
    }
    if (line.hasOption("buildmodule")) {
        File buildModule = new File(line.getOptionValue("buildmodule").replace('/', File.separatorChar));
        easyAntConfiguration.setBuildModule(buildModule);
    }
    if (line.hasOption("buildfile")) {
        File buildFile = new File(line.getOptionValue("buildfile").replace('/', File.separatorChar));
        easyAntConfiguration.setBuildFile(buildFile);
    }
    if (line.hasOption("buildconf")) {
        easyAntConfiguration.getActiveBuildConfigurations().add(line.getOptionValue("buildconf"));
    }

    File easyantConfFile = null;

    if (line.hasOption("configfile")) {
        easyantConfFile = new File(line.getOptionValue("configfile").replace('/', File.separatorChar));
    } else {
        // if no command line switch is specified check the default location

        File easyantHome = new File(
                System.getProperty(EasyAntMagicNames.EASYANT_HOME).replace('/', File.separatorChar));
        File defaultGlobalEasyantConfFile = new File(easyantHome,
                EasyAntConstants.DEFAULT_GLOBAL_EASYANT_CONF_FILE);

        if (defaultGlobalEasyantConfFile.exists()) {
            easyantConfFile = defaultGlobalEasyantConfFile;
        }
    }

    if (easyantConfFile != null) {
        try {
            easyAntConfiguration = EasyantConfigurationFactory.getInstance()
                    .createConfigurationFromFile(easyAntConfiguration, easyantConfFile.toURI().toURL());
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }

    if (line.hasOption("listener")) {
        easyAntConfiguration.getListeners().add(line.getOptionValue("listener"));
    }
    if (line.hasOption("D")) {
        easyAntConfiguration.getDefinedProps().putAll(line.getOptionProperties("D"));
    }
    if (line.hasOption("logger")) {
        if (easyAntConfiguration.getLoggerClassname() != null) {
            throw new BuildException("Only one logger class may be specified.");
        }
        easyAntConfiguration.setLoggerClassname(line.getOptionValue("logger"));
    }
    if (line.hasOption("inputhandler")) {
        if (easyAntConfiguration.getInputHandlerClassname() != null) {
            throw new BuildException("Only one input handler class may " + "be specified.");
        }
        easyAntConfiguration.setInputHandlerClassname(line.getOptionValue("inputhandler"));
    }
    if (line.hasOption("emacs")) {
        easyAntConfiguration.setEmacsMode(true);
    }
    if (line.hasOption("projecthelp")) {
        // set the flag to display the targets and quit
        projectHelp = true;
    }
    if (line.hasOption("find")) {
        // eat up next arg if present, default to module.ivy
        if (line.getOptionValues("find").length > 0) {
            searchForThis = line.getOptionValue("find");

        } else {
            searchForThis = EasyAntConstants.DEFAULT_BUILD_MODULE;
        }
        easyAntConfiguration.setBuildModule(new File(searchForThis));
        easyAntConfiguration.setBuildModuleLookupEnabled(true);
    }
    if (line.hasOption("propertyfile")) {
        propertyFiles.add(line.getOptionValue("propertyfile"));
    }
    if (line.hasOption("keep-going")) {
        easyAntConfiguration.setKeepGoingMode(true);
    }
    if (line.hasOption("offline")) {
        easyAntConfiguration.setOffline(true);
    }
    if (line.hasOption("nice")) {
        easyAntConfiguration.setThreadPriority(Integer.decode(line.getOptionValue("nice")));

        if (easyAntConfiguration.getThreadPriority() < Thread.MIN_PRIORITY
                || easyAntConfiguration.getThreadPriority() > Thread.MAX_PRIORITY) {
            throw new BuildException("Niceness value is out of the range 1-10");
        }
    }
    if (line.hasOption("autoproxy")) {
        easyAntConfiguration.setProxy(true);
    }
    if (!line.getArgList().isEmpty()) {
        for (Object o : line.getArgList()) {
            String target = (String) o;
            easyAntConfiguration.getTargets().add(target);
        }
    }

    // Load the property files specified by -propertyfile
    loadPropertyFiles();

    if (logTo != null) {
        easyAntConfiguration.setOut(logTo);
        easyAntConfiguration.setErr(logTo);
        System.setOut(easyAntConfiguration.getOut());
        System.setErr(easyAntConfiguration.getErr());
    }
    readyToRun = true;
}

From source file:org.apache.hadoop.hive.metastore.tools.TestSchemaToolForMetastore.java

/**
 * Test schema upgrade/*from   ww w.  ja v a  2 s . c om*/
 */
@Test
public void testSchemaUpgrade() throws Exception {
    boolean foundException = false;
    // Initialize 1.2.0 schema
    execute(new SchemaToolTaskInit(), "-initSchemaTo 1.2.0");
    // verify that driver fails due to older version schema
    try {
        schemaTool.verifySchemaVersion();
    } catch (HiveMetaException e) {
        // Expected to fail due to old schema
        foundException = true;
    }
    if (!foundException) {
        throw new Exception("Hive operations shouldn't pass with older version schema");
    }

    // Generate dummy pre-upgrade script with errors
    String invalidPreUpgradeScript = writeDummyPreUpgradeScript(0, "upgrade-2.3.0-to-3.0.0.derby.sql",
            "foo bar;");
    // Generate dummy pre-upgrade scripts with valid SQL
    String validPreUpgradeScript0 = writeDummyPreUpgradeScript(1, "upgrade-2.3.0-to-3.0.0.derby.sql",
            "CREATE TABLE schema_test0 (id integer);");
    String validPreUpgradeScript1 = writeDummyPreUpgradeScript(2, "upgrade-2.3.0-to-3.0.0.derby.sql",
            "CREATE TABLE schema_test1 (id integer);");

    // Capture system out and err
    schemaTool.setVerbose(true);
    OutputStream stderr = new ByteArrayOutputStream();
    PrintStream errPrintStream = new PrintStream(stderr);
    System.setErr(errPrintStream);
    OutputStream stdout = new ByteArrayOutputStream();
    PrintStream outPrintStream = new PrintStream(stdout);
    System.setOut(outPrintStream);

    // Upgrade schema from 0.7.0 to latest
    execute(new SchemaToolTaskUpgrade(), "-upgradeSchemaFrom 1.2.0");

    // Verify that the schemaTool ran pre-upgrade scripts and ignored errors
    Assert.assertTrue(stderr.toString().contains(invalidPreUpgradeScript));
    Assert.assertTrue(stderr.toString().contains("foo"));
    Assert.assertFalse(stderr.toString().contains(validPreUpgradeScript0));
    Assert.assertFalse(stderr.toString().contains(validPreUpgradeScript1));
    Assert.assertTrue(stdout.toString().contains(validPreUpgradeScript0));
    Assert.assertTrue(stdout.toString().contains(validPreUpgradeScript1));

    // Verify that driver works fine with latest schema
    schemaTool.verifySchemaVersion();
}

From source file:org.eclipse.virgo.medic.impl.LogController.java

private synchronized void updateLogConfiguration(Dictionary<String, Object> configuration) {
    String logSysOutConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSOUT);
    if (Boolean.valueOf(logSysOutConfiguration)) {
        delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut,
                LOGGER_NAME_SYSOUT_DELEGATE);
        sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT);

        System.setOut(wrapPrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor,
                configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT));
    } else {//www  .j  a va 2 s.co  m
        if (Boolean.FALSE.toString().equals(logSysOutConfiguration)) {
            if (delegatingSysOutRegistration != null) {
                registrationTracker.unregister(delegatingSysOutRegistration);
                delegatingSysOutRegistration = null;
            }
            if (sysOutRegistration != null) {
                registrationTracker.unregister(sysOutRegistration);
                sysOutRegistration = null;
            }
            System.setOut((PrintStream) delegatingSysOut);
        } else {
            delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut,
                    LOGGER_NAME_SYSOUT_DELEGATE);
            sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT);

            System.setOut(decoratePrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor,
                    configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT));

            if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysOutConfiguration)) {
                System.out.println("Invalid value '" + logSysOutConfiguration + "' for configuration key '"
                        + ConfigurationProvider.KEY_LOG_WRAP_SYSOUT
                        + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'.");
            }
        }
    }

    String logSysErrConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSERR);
    if (Boolean.valueOf(logSysErrConfiguration)) {
        delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr,
                LOGGER_NAME_SYSERR_DELEGATE);
        sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR);

        System.setErr(wrapPrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor,
                configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR));
    } else {
        if (Boolean.FALSE.toString().equals(logSysErrConfiguration)) {
            if (delegatingSysErrRegistration != null) {
                registrationTracker.unregister(delegatingSysErrRegistration);
                delegatingSysErrRegistration = null;
            }
            if (sysErrRegistration != null) {
                registrationTracker.unregister(sysErrRegistration);
                sysErrRegistration = null;
            }
            System.setErr((PrintStream) delegatingSysErr);
        } else {
            delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr,
                    LOGGER_NAME_SYSERR_DELEGATE);
            sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR);

            System.setErr(decoratePrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor,
                    configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR));

            if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysErrConfiguration)) {
                System.err.println("Invalid value '" + logSysErrConfiguration + "' for configuration key '"
                        + ConfigurationProvider.KEY_LOG_WRAP_SYSERR
                        + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'.");
            }
        }
    }

    if (Boolean.valueOf((String) configuration.get(ConfigurationProvider.KEY_ENABLE_JUL_CONSOLE_HANDLER))) {
        enableJulConsoleLogger();
    } else {
        disableJulConsoleHandler();
    }
}

From source file:edu.umn.natsrl.ticas.plugin.srte.SRTEMainPanel.java

/**
 * Redirect output into log box//from   ww w.  j  a v a2 s .c o  m
 */
public void redirectOutput() {
    backupOut = System.out;
    backupErr = System.err;
    //reset Area
    jTextArea1.setText("");
    // redirect System.out and System.err to log textbox
    StringOutputStream sos = new StringOutputStream(this.jTextArea1);
    System.setOut(new PrintStream(sos));
    System.setErr(new PrintStream(sos));
}

From source file:edu.umn.natsrl.ticas.plugin.srte.SRTEMainPanel.java

/**
 * Resotre output/*from  w  ww. j  ava2 s  .  co  m*/
 */
public void restoreOutput() {
    if (backupOut == null)
        return;
    System.setOut(backupOut);
    System.setErr(backupErr);
}

From source file:org.graphwalker.machines.ExtendedFiniteStateMachine.java

@Override
public void setCalculatingPath(boolean calculatingPath) {
    super.setCalculatingPath(calculatingPath);
    if (calculatingPath && this.oldPrintStream != System.out) {
        this.oldPrintStream = System.out;
        System.setOut(new VoidPrintStream());
    } else if (!calculatingPath && this.oldPrintStream != System.out) {
        System.setOut(this.oldPrintStream);
    }/*from   w  w w. j  av a 2 s. c o m*/
}

From source file:com.salmonllc.ideTools.Tomcat50Engine.java

/**
 * Start a new server instance./*from  w w  w  .  j  a  v a2  s.com*/
 */
public void load() {
    initDirs();

    // Before digester - it may be needed

    initNaming();

    // Create and execute our Digester
    Digester digester = createStartDigester();
    long t1 = System.currentTimeMillis();

    Exception ex = null;
    InputSource inputSource = null;
    InputStream inputStream = null;
    try {
        File file = configFile();
        inputStream = new FileInputStream(file);
        inputSource = new InputSource("file://" + file.getAbsolutePath());
    } catch (Exception e) {
        ;
    }
    if (inputStream == null) {
        try {
            inputStream = getClass().getClassLoader().getResourceAsStream(getConfigFile());
            inputSource = new InputSource(getClass().getClassLoader().getResource(getConfigFile()).toString());
        } catch (Exception e) {
            ;
        }
    }

    if (inputStream == null) {
        System.out.println("Can't load server.xml");
        return;
    }

    try {
        inputSource.setByteStream(inputStream);
        digester.push(this);
        digester.parse(inputSource);
        inputStream.close();
    } catch (Exception e) {
        System.out.println("Catalina.start using " + getConfigFile() + ": " + e);
        e.printStackTrace(System.out);
        return;
    }

    // Replace System.out and System.err with a custom PrintStream
    // TODO: move to Embedded, make it configurable
    SystemLogHandler systemlog = new SystemLogHandler(System.out);
    System.setOut(systemlog);
    System.setErr(systemlog);

    // Start the new server
    if (_server instanceof Lifecycle) {
        try {
            _server.initialize();
        } catch (LifecycleException e) {
            log.error("Catalina.start", e);
        }
    }

    long t2 = System.currentTimeMillis();
    log.info("Initialization processed in " + (t2 - t1) + " ms");

}

From source file:lcmc.LCMC.java

/** Inits the application. */
protected static String initApp(final String[] args) {
    try {//from   ww w. j  a  v  a 2  s.  c  o  m
        /* Metal */
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        MetalLookAndFeel.setCurrentTheme(new OceanTheme() {
            /** e.g. arrows on split pane... */
            protected ColorUIResource getPrimary1() {
                return new ColorUIResource(ClusterBrowser.STATUS_BACKGROUND);
            }

            /** unknown to me */
            protected ColorUIResource getPrimary2() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** unknown to me */
            protected ColorUIResource getPrimary3() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** Button and other borders. */
            protected ColorUIResource getSecondary1() {
                return new ColorUIResource(AppDefaults.BACKGROUND_DARK);
            }

            protected ColorUIResource getSecondary2() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** Split pane divider. Line in the main menu. */
            protected ColorUIResource getSecondary3() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }
        });
    } catch (final Exception e) {
        /* ignore it then */
    }
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(final Thread t, final Throwable ex) {
            Tools.appError("uncaught exception", ex.toString(), (Exception) ex);
        }
    });
    float fps = 20.0f;
    final Options options = new Options();

    options.addOption("h", HELP_OP, false, "print this help");
    options.addOption(null, KEEP_HELPER_OP, false, "do not overwrite the lcmc-gui-helper program");
    options.addOption(null, RO_OP, false, "read only mode");
    options.addOption(null, OP_OP, false, "operator mode");
    options.addOption(null, ADMIN_OP, false, "administrator mode");
    options.addOption(null, OP_MODE_OP, true, "operating mode. <arg> can be:\n" + "ro - read only\n"
            + "op - operator\n" + "admin - administrator");
    options.addOption(null, NOLRM_OP, false, "do not show removed resources from LRM.");
    options.addOption(null, "auto", true, "for testing");
    options.addOption("v", VERSION_OP, false, "print version");
    options.addOption(null, AUTO_OP, true, "for testing");
    options.addOption(null, NO_UPGRADE_CHECK_OP, false, "disable upgrade check");
    options.addOption(null, NO_PLUGIN_CHECK_OP, false,
            "disable plugin check, DEPRECATED: there are no plugins");
    options.addOption(null, TIGHTVNC_OP, false, "enable tight vnc viewer");
    options.addOption(null, ULTRAVNC_OP, false, "enable ultra vnc viewer");
    options.addOption(null, REALVNC_OP, false, "enable real vnc viewer");
    options.addOption(null, BIGDRBDCONF_OP, false,
            "create one big drbd.conf, instead of many" + " files in drbd.d/ directory");
    options.addOption(null, STAGING_DRBD_OP, false, "enable more DRBD installation options");
    options.addOption(null, STAGING_PACEMAKER_OP, false, "enable more Pacemaker installation options");
    options.addOption(null, VNC_PORT_OFFSET_OP, true, "offset for port forwarding");
    options.addOption(null, SLOW_OP, false, "specify this if you have slow computer");
    options.addOption(null, RESTORE_MOUSE_OP, false, "for testing");
    options.addOption(null, SCALE_OP, true, "scale fonts and sizes of elements in percent (100)");
    options.addOption(null, ID_DSA_OP, true, "location of id_dsa file ($HOME/.ssh/id_dsa)");
    options.addOption(null, ID_RSA_OP, true, "location of id_rsa file ($HOME/.ssh/id_rsa)");
    options.addOption(null, KNOWN_HOSTS_OP, true, "location of known_hosts file ($HOME/.ssh/known_hosts)");
    options.addOption(null, OUT_OP, true, "where to redirect the standard out");
    options.addOption(null, DEBUG_OP, true, "debug level, 0 - none, 3 - all");
    options.addOption("c", CLUSTER_OP, true, "define a cluster");
    final Option hostOp = new Option("h", HOST_OP, true, "define a cluster, used with --cluster option");
    hostOp.setArgs(10000);
    options.addOption(hostOp);
    options.addOption(null, SUDO_OP, false, "whether to use sudo, used with --cluster option");
    options.addOption(null, USER_OP, true, "user to use with sudo, used with --cluster option");
    options.addOption(null, PORT_OP, true, "ssh port, used with --cluster option");
    options.addOption(null, ADVANCED_OP, false, "start in an advanced mode");
    options.addOption(null, ONE_HOST_CLUSTER_OP, false, "allow one host cluster");
    final CommandLineParser parser = new PosixParser();
    String autoArgs = null;
    try {
        final CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption(OUT_OP)) {
            final String out = cmd.getOptionValue(OUT_OP);
            if (out != null) {
                try {
                    System.setOut(new PrintStream(new FileOutputStream(out)));
                } catch (final FileNotFoundException e) {
                    System.exit(2);
                }
            }
        }
        if (cmd.hasOption(DEBUG_OP)) {
            final String level = cmd.getOptionValue(DEBUG_OP);
            if (level != null && Tools.isNumber(level)) {
                Tools.setDebugLevel(Integer.parseInt(level));
            } else {
                throw new ParseException("cannot parse debug level: " + level);
            }
        }
        boolean tightvnc = cmd.hasOption(TIGHTVNC_OP);
        boolean ultravnc = cmd.hasOption(ULTRAVNC_OP);
        final boolean realvnc = cmd.hasOption(REALVNC_OP);
        if (!tightvnc && !ultravnc && !realvnc) {
            if (Tools.isLinux()) {
                tightvnc = true;
            } else if (Tools.isWindows()) {
                ultravnc = true;
            } else {
                tightvnc = true;
                ultravnc = true;
            }
        }
        boolean advanced = cmd.hasOption(ADVANCED_OP);
        Tools.getConfigData().setAdvancedMode(advanced);
        Tools.getConfigData().setTightvnc(tightvnc);
        Tools.getConfigData().setUltravnc(ultravnc);
        Tools.getConfigData().setRealvnc(realvnc);

        Tools.getConfigData().setUpgradeCheckEnabled(!cmd.hasOption(NO_UPGRADE_CHECK_OP));
        Tools.getConfigData().setBigDRBDConf(cmd.hasOption(BIGDRBDCONF_OP));
        Tools.getConfigData().setStagingDrbd(cmd.hasOption(STAGING_DRBD_OP));
        Tools.getConfigData().setStagingPacemaker(cmd.hasOption(STAGING_PACEMAKER_OP));
        Tools.getConfigData().setNoLRM(cmd.hasOption(NOLRM_OP));
        Tools.getConfigData().setKeepHelper(cmd.hasOption(KEEP_HELPER_OP));
        Tools.getConfigData().setOneHostCluster(cmd.hasOption(ONE_HOST_CLUSTER_OP));
        final String pwd = System.getProperty("user.home");
        final String scaleOp = cmd.getOptionValue(SCALE_OP, "100");
        try {
            final int scale = Integer.parseInt(scaleOp);
            Tools.getConfigData().setScale(scale);
            Tools.resizeFonts(scale);
        } catch (java.lang.NumberFormatException e) {
            Tools.appWarning("cannot parse scale: " + scaleOp);
        }

        final String idDsaPath = cmd.getOptionValue(ID_DSA_OP, pwd + "/.ssh/id_dsa");
        final String idRsaPath = cmd.getOptionValue(ID_RSA_OP, pwd + "/.ssh/id_rsa");
        final String knownHostsPath = cmd.getOptionValue(KNOWN_HOSTS_OP, pwd + "/.ssh/known_hosts");
        Tools.getConfigData().setIdDSAPath(idDsaPath);
        Tools.getConfigData().setIdRSAPath(idRsaPath);
        Tools.getConfigData().setKnownHostPath(knownHostsPath);

        final String opMode = cmd.getOptionValue(OP_MODE_OP);
        autoArgs = cmd.getOptionValue(AUTO_OP);
        if (cmd.hasOption(HELP_OP)) {
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("java -jar LCMC.jar [OPTIONS]", options);
            System.exit(0);
        }
        if (cmd.hasOption(VERSION_OP)) {
            System.out.println("LINUX CLUSTER MANAGEMENT CONSOLE " + Tools.getRelease() + " by Rasto Levrinc");
            System.exit(0);
        }
        if (cmd.hasOption("ro") || "ro".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.RO);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.RO);
        } else if (cmd.hasOption("op") || "op".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.OP);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.OP);
        } else if (cmd.hasOption("admin") || "admin".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.ADMIN);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.ADMIN);
        } else if (opMode != null) {
            Tools.appWarning("unknown operating mode: " + opMode);
        }
        if (cmd.hasOption(SLOW_OP)) {
            fps = fps / 2;
        }
        if (cmd.hasOption(RESTORE_MOUSE_OP)) {
            /* restore mouse if it is stuck in pressed state, during
             * robot tests. */
            RoboTest.restoreMouse();
        }
        final String vncPortOffsetString = cmd.getOptionValue(VNC_PORT_OFFSET_OP);
        if (vncPortOffsetString != null && Tools.isNumber(vncPortOffsetString)) {
            Tools.getConfigData().setVncPortOffset(Integer.parseInt(vncPortOffsetString));
        }
        Tools.getConfigData().setAnimFPS(fps);
        if (cmd.hasOption(CLUSTER_OP) || cmd.hasOption(HOST_OP)) {
            parseClusterOptions(cmd);
        }
    } catch (ParseException exp) {
        System.out.println("ERROR: " + exp.getMessage());
        System.exit(1);
    }
    Tools.debug(null, "max mem: " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "m", 1);
    return autoArgs;
}