List of usage examples for java.util.logging Level OFF
Level OFF
To view the source code for java.util.logging Level OFF.
Click Source Link
From source file:net.demilich.metastone.bahaviour.ModifiedMCTS.MCTSCritique.java
@Override public synchronized double getCritique(GameContext context, Player p) { java.util.logging.Logger.getLogger(caffe.class.getSimpleName()).setLevel(Level.OFF); ;// w w w. j a v a 2 s. c o m context = context.clone(); p = context.getPlayer(p.getId()); Caffe.set_mode(Caffe.CPU); //System.err.println("network is " + network + " " + context + " " + f); double input[] = f.getFeatures(true, context, p); if (input.length != 169) { System.err.println("heyyyoo"); System.exit(0); } //System.err.println("input length is " + input.length); int hash = 0; for (int i = 0; i < input.length; i++) { hash += (i + 1) * (input[i] + i); } //System.err.println("hash is " + hash); String paramFile = "/home/dfreelan/dev/networks/singleLayerExample.prototxt"; // System.err.println("HPASE IS: " + caffe_net.phase()); java.util.logging.Logger.getGlobal().setLevel(Level.OFF); //caffe_net.ClearParamDiffs(); FloatBlob dataBlob = caffe_net.blob_by_name("data"); //dataBlob.Reshape(169, 1, 1, 1); dataBlob.set_cpu_data(toFloats(input)); dataBlob.Update(); dataBlob.Update(); // System.err.println("bott blob length? " + bottom.size()); //FloatBlobVector top = caffe_net.ForwardPrefilled(); caffe_net.ForwardFrom(1); float out = caffe_net.blob_by_name("tanhFinal").cpu_data().get(); dataBlob.set_cpu_data(new float[169]); dataBlob.Update(); dataBlob.Update(); // System.err.println("bott blob length? " + bottom.size()); //FloatBlobVector top = caffe_net.ForwardPrefilled(); caffe_net.ForwardFrom(1); float out2 = caffe_net.blob_by_name("tanhFinal").cpu_data().get(); if (Float.isNaN(out) || out2 == out) { System.err.println("is nan you or producing same output..." + out + " " + out2); out = 0; //f.printFeatures(context, p); // modelFile = "/home/dfreelan/dev/networks/_iter_350000.caffemodel"; paramFile = "/home/dfreelan/dev/networks/singleLayerExample.prototxt"; Caffe.set_mode(Caffe.CPU); try { //String str = FileUtils.readFileToString(new File(paramFile), "utf-8"); ///System.err.println(str); if (modelFile != null) { caffe_net = new FloatNet(paramFile, TEST); caffe_net.CopyTrainedLayersFrom(modelFile); } } catch (Exception e) { e.printStackTrace(); System.exit(0); } return getCritique(context, p); } //System.err.println(" i made a deicsion! " + out); return (out + 1.0) / 2.0; //NeuralDataSet sample = new BasicNeuralDataSet(new double[][] //{ f.getFeatures(true, context, context.getPlayer(playerID)) }); }
From source file:com.all.rds.loader.util.JAudioTaggerMetadataReader.java
private void turnOffLogMessages() { try {// w w w. jav a 2 s . c o m Handler[] handlers = Logger.getLogger("").getHandlers(); for (int index = 0; index < handlers.length; index++) { handlers[index].setLevel(Level.OFF); } } catch (Exception e) { LOGGER.warn("Could not disable JAudioTagger logs."); } }
From source file:org.jas.metadata.MetadataReader.java
private void turnOffLogMessages() { Handler[] handlers = Logger.getLogger("").getHandlers(); for (int index = 0; index < handlers.length; index++) { handlers[index].setLevel(Level.OFF); }/* w w w . ja v a 2 s .c o m*/ }
From source file:ffx.numerics.LBFGS.java
/** * This method solves the unconstrained minimization problem * <pre>//from w w w . jav a2 s. com * min f(x), x = (x1,x2,...,x_n), * </pre> using the limited-memory BFGS method. The routine is especially * effective on problems involving a large number of variables. In a typical * iteration of this method an approximation <code>Hk</code> to the inverse * of the Hessian is obtained by applying <code>m</code> BFGS updates to a * diagonal matrix <code>Hk0</code>, using information from the previous * <code>m</code> steps. * * The user specifies the number <code>m</code>, which determines the amount * of storage required by the routine. * * The user is required to calculate the function value <code>f</code> and * its gradient <code>g</code>. * * The steplength is determined at each iteration by means of the line * search routine <code>lineSearch</code>, which is a slight modification of * the routine <code>CSRCH</code> written by More' and Thuente. * * @param n The number of variables in the minimization problem. * Restriction: <code>n > 0</code>. * @param mSave The number of corrections used in the BFGS update. Values of * <code>mSave</code> less than 3 are not recommended; large values of * <code>mSave</code> will result in excessive computing time. * <code>3 <= mSave <= 7</code> is recommended. * Restriction: * <code>mSave > 0</code>. * @param x On initial entry this must be set by the user to the values of * the initial estimate of the solution vector. On exit it contains the * values of the variables at the best point found (usually a solution). * @param f The value of the function <code>f</code> at the point * <code>x</code>. * @param g The components of the gradient <code>g</code> at the point * <code>x</code>. * @param eps Determines the accuracy with which the solution is to be * found. The subroutine terminates when <code> * G RMS < EPS * </code> * @param maxIterations Maximum number of optimization steps. * @param potential Implements the {@link Potential} interface to supply * function values and gradients. * @param listener Implements the {@link OptimizationListener} interface and * will be notified after each successful step. * @return status code (0 = success, 1 = max iterations reached, -1 = * failed) * @since 1.0 */ public static int minimize(final int n, int mSave, final double[] x, double f, double[] g, final double eps, final int maxIterations, Potential potential, OptimizationListener listener) { assert (n > 0); assert (mSave > 0); assert (maxIterations > 0); assert (x != null && x.length >= n); assert (g != null && g.length >= n); if (mSave > n) { logger.fine(format(" Resetting the number of saved L-BFGS vectors to %d.", n)); mSave = n; } int iterations = 0; int evaluations = 1; int nErrors = 0; int maxErrors = 2; double rms = sqrt(n); double scaling[] = potential.getScaling(); if (scaling == null) { scaling = new double[n]; fill(scaling, 1.0); } /** * Initial search direction is the steepest decent direction. */ double s[][] = new double[mSave][n]; double y[][] = new double[mSave][n]; for (int i = 0; i < n; i++) { s[0][i] = -g[i]; } double grms = 0.0; double gnorm = 0.0; for (int i = 0; i < n; i++) { double gi = g[i]; if (gi == Double.NaN || gi == Double.NEGATIVE_INFINITY || gi == Double.POSITIVE_INFINITY) { String message = format("The gradient of variable %d is %8.3f.", i, gi); logger.warning(message); return 1; } double gis = gi * scaling[i]; gnorm += gi * gi; grms += gis * gis; } gnorm = sqrt(gnorm); grms = sqrt(grms) / rms; /** * Notify the listeners of initial conditions. */ if (listener != null) { if (!listener.optimizationUpdate(iterations, evaluations, grms, 0.0, f, 0.0, 0.0, null)) { /** * Terminate the optimization. */ return 1; } } else { log(iterations, evaluations, grms, 0.0, f, 0.0, 0.0, null); } /** * The convergence criteria may already be satisfied. */ if (grms <= eps) { return 0; } final double prevX[] = new double[n]; final double prevG[] = new double[n]; final double r[] = new double[n]; final double p[] = new double[n]; final double h0[] = new double[n]; final double q[] = new double[n]; final double alpha[] = new double[mSave]; final double rho[] = new double[mSave]; double gamma = 1.0; /** * Line search parameters. */ final LineSearch lineSearch = new LineSearch(n); final LineSearchResult info[] = { LineSearchResult.Success }; final int nFunctionEvals[] = { 0 }; final double angle[] = { 0.0 }; double df = 0.5 * STEPMAX * gnorm; int m = -1; while (true) { iterations++; if (iterations > maxIterations) { logger.info(format(" Maximum number of iterations reached: %d.", maxIterations)); return 1; } int muse = min(iterations - 1, mSave); m++; if (m > mSave - 1) { m = 0; } /** * Estimate the Hessian Diagonal. */ fill(h0, gamma); arraycopy(g, 0, q, 0, n); int k = m; for (int j = 0; j < muse; j++) { k--; if (k < 0) { k = mSave - 1; } alpha[k] = XdotY(n, s[k], 0, 1, q, 0, 1); alpha[k] *= rho[k]; aXplusY(n, -alpha[k], y[k], 0, 1, q, 0, 1); } for (int i = 0; i < n; i++) { r[i] = h0[i] * q[i]; } for (int j = 0; j < muse; j++) { double beta = XdotY(n, r, 0, 1, y[k], 0, 1); beta *= rho[k]; aXplusY(n, alpha[k] - beta, s[k], 0, 1, r, 0, 1); k++; if (k > mSave - 1) { k = 0; } } /** * Set the search direction. */ for (int i = 0; i < n; i++) { p[i] = -r[i]; } arraycopy(x, 0, prevX, 0, n); arraycopy(g, 0, prevG, 0, n); /** * Perform the line search along the new conjugate direction. */ nFunctionEvals[0] = 0; double prevF = f; f = lineSearch.search(n, x, f, g, p, angle, df, info, nFunctionEvals, potential); evaluations += nFunctionEvals[0]; /** * Update variables based on the results of this iteration. */ for (int i = 0; i < n; i++) { s[m][i] = x[i] - prevX[i]; y[m][i] = g[i] - prevG[i]; } double ys = XdotY(n, y[m], 0, 1, s[m], 0, 1); double yy = XdotY(n, y[m], 0, 1, y[m], 0, 1); gamma = abs(ys / yy); rho[m] = 1.0 / ys; /** * Get the sizes of the moves made during this iteration. */ df = prevF - f; double xrms = 0.0; grms = 0.0; for (int i = 0; i < n; i++) { double dx = (x[i] - prevX[i]) / scaling[i]; xrms += dx * dx; double gx = g[i] * scaling[i]; grms += gx * gx; } xrms = sqrt(xrms) / rms; grms = sqrt(grms) / rms; boolean done = false; if (info[0] == LineSearchResult.BadIntpln || info[0] == LineSearchResult.IntplnErr) { nErrors++; if (nErrors >= maxErrors) { logger.log(Level.OFF, " Algorithm failure: bad interpolation."); done = true; } } else { nErrors = 0; } if (listener != null) { if (!listener.optimizationUpdate(iterations, evaluations, grms, xrms, f, df, angle[0], info[0])) { /** * Terminate the optimization. */ return 1; } } else { log(iterations, evaluations, grms, xrms, f, df, angle[0], info[0]); } /** * Terminate the optimization if the line search failed or upon * satisfying the convergence criteria. */ if (done) { return -1; } else if (grms <= eps) { return 0; } } }
From source file:de.uni_koblenz.jgralab.utilities.tg2dot.Tg2Dot.java
@Override protected void graphStart(PrintStream out) { // Disable debugging to prevent recursive execution and restore it in // graphEnd() jGraLabLogLevel = JGraLab.getRootLogger().getLevel(); JGraLab.setLogLevel(Level.OFF); initializeEvaluator();//from w w w . ja v a2 s. c o m initializeGraphLayout(); setGlobalVariables(); setCommandLineVariables(); createDotWriter(out); startDotGraph(); }
From source file:org.finra.jtaf.ewd.impl.DefaultSessionFactory.java
@Override public DesiredCapabilities createCapabilities(Map<String, String> options) throws Exception { ClientProperties properties = new ClientProperties(options.get("client")); final String browser = properties.getBrowser(); if (properties.isUseGrid()) { DesiredCapabilities capabilities = null; if (properties.getGridUrl().length() == 0) { throw new Exception("You must provide 'grid.url' to use Selenium Grid in client property file"); }//from ww w. j a va2 s. c om if (browser.length() == 0) { throw new Exception("You must provide 'browser' to use Selenium Grid in client property file"); } if (properties.getGridPlatform().length() == 0) { throw new Exception( "You must provide 'grid.platform' to use Selenium Grid in client property file"); } if (browser.equalsIgnoreCase("ie") || browser.equalsIgnoreCase("iexplore") || browser.equalsIgnoreCase("*iexplore")) { capabilities = DesiredCapabilities.internetExplorer(); } else if ((browser.equalsIgnoreCase("firefox") || browser.equalsIgnoreCase("*firefox"))) { capabilities = DesiredCapabilities.firefox(); } else if (browser.equalsIgnoreCase("chrome")) { capabilities = DesiredCapabilities.chrome(); } else if (browser.equalsIgnoreCase("safari")) { capabilities = DesiredCapabilities.safari(); } else if (browser.equalsIgnoreCase("opera")) { capabilities = DesiredCapabilities.opera(); } else if (browser.equalsIgnoreCase("android")) { capabilities = DesiredCapabilities.android(); } else if (browser.equalsIgnoreCase("ipad")) { capabilities = DesiredCapabilities.ipad(); } else if (browser.equalsIgnoreCase("iphone")) { capabilities = DesiredCapabilities.iphone(); } else { log.fatal("Unsupported browser: " + browser + " Please refer to documentation for supported browsers."); } capabilities.setVersion(properties.getBrowserVersion()); String platform = properties.getGridPlatform(); if (platform != null && platform.length() > 0) { capabilities.setCapability("platform", platform); } else { // Default to Windows 7 capabilities.setCapability("platform", "Windows 7"); } // Set Proxy String proxyStr = properties.getProxy(); String proxyHttps = properties.getProxyHttps(); Proxy proxy = null; if (proxyStr != null && !proxyStr.equals("")) { proxy = new Proxy(); proxy.setHttpProxy(proxyStr); } if (proxyHttps != null && !proxyHttps.equals("")) { if (proxy == null) { proxy = new Proxy(); } proxy.setSslProxy(proxyHttps); } if (proxy != null) { capabilities.setCapability(CapabilityType.PROXY, proxy); } // preparing data for session name String computerName = null; try { computerName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { } capabilities.setCapability("name", "JTAF EWD client=" + properties.getClient() + "; started from " + computerName); String gridProperties = properties.getGridProperties(); if (gridProperties != null && gridProperties.length() > 0) { String[] gridPropertiesSlpitted = gridProperties.split(" "); for (String gridPropertiesSlpittedCurrent : gridPropertiesSlpitted) { if (gridPropertiesSlpittedCurrent != null && gridPropertiesSlpittedCurrent.length() > 0) { String[] propertyNameAndValue = gridPropertiesSlpittedCurrent.split("="); if (propertyNameAndValue.length == 2) { capabilities.setCapability(propertyNameAndValue[0], propertyNameAndValue[1]); } } } } return capabilities; } else { log.debug("browser [" + browser + "]"); // Turning off all console logs using java.util.logging Handler[] h = java.util.logging.LogManager.getLogManager().getLogger("").getHandlers(); for (int i = 0; i < h.length; i++) { if (h[i] instanceof ConsoleHandler) { h[i].setLevel(Level.OFF); } } String proxyProperty = properties.getProxy(); DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); if (proxyProperty != null) { Proxy proxy = new Proxy(); proxy.setHttpProxy(proxyProperty).setFtpProxy(proxyProperty).setSslProxy(proxyProperty); desiredCapabilities = new DesiredCapabilities(); if (browser != null && browser.equalsIgnoreCase("chrome")) { // chrome way of proxy initialization desiredCapabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://" + proxy)); } else { // ff and ie way of proxy initialization desiredCapabilities.setCapability(CapabilityType.PROXY, proxy); } } if (properties.getDownloadFolder() != null && properties.getDownloadFolder().length() > 0) { // '0' means to download to the desktop, '1' means to download // to the default "Downloads" directory, '2' means to use the // directory you specify in "browser.download.dir" desiredCapabilities.setCapability("browser.download.folderList", 2); desiredCapabilities.setCapability("browser.download.dir", System.getProperty("user.dir") + System.getProperty("file.separator") + properties.getDownloadFolder()); desiredCapabilities.setCapability("browser.helperApps.neverAsk.saveToDisk", "text/csv, application/octet-stream, application/pdf, application/vnd.fdf, application/x-msdos-program, application/x-unknown-application-octet-stream, application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel, application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip,application/x-stuffit,application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar, video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff"); desiredCapabilities.setCapability("browser.helperApps.alwaysAsk.force", false); desiredCapabilities.setCapability("browser.download.manager.showWhenStarting", false); } return desiredCapabilities; } }
From source file:edu.usu.sdl.openstorefront.web.rest.service.Application.java
private List<String> loadLevels() { List<String> logLevels = Arrays.asList(Level.OFF.getName(), Level.SEVERE.getName(), Level.WARNING.getName(), Level.CONFIG.getName(), Level.INFO.getName(), Level.FINE.getName(), Level.FINER.getName(), Level.FINEST.getName(), Level.ALL.getName()); return logLevels; }
From source file:alma.acs.logging.AcsLogger.java
/** * Logs the given <code>LogRecord</code>. * The record can be modified or dropped by the optional filters provided in {@link #addLogRecordFilter(alma.acs.logging.AcsLogger.LogRecordFilter)}. * <p>// w ww .jav a2 s.co m * Adding of context information: * <ul> * <li> If the LogRecord has a parameter that is a map which contains additional information * about the line of code, thread, etc., the log record will be taken as provided, and no context * information will be added. This can be useful if * <ul> * <li> the log record was reconstructed from a remote error by the ACS error handling code * (see <code>AcsJException</code>), or * <li> if in very exceptional cases application code needs to manipulate such information by hand. * </ul> * <li> otherwise, context information is inferred, similar to {@link LogRecord#inferCaller()}, * but additionally including thread name and line of code. * </ul> * Note that by overloading this method, we intercept all logging activities of the base class. * * @see java.util.logging.Logger#log(java.util.logging.LogRecord) */ public void log(LogRecord record) { // Throw exception if level OFF was used to log this record, see http://jira.alma.cl/browse/COMP-1928 // Both Level.OFF and AcsLogLevel.OFF use the same value INTEGER.max, but we anyway check for both. if (record.getLevel().intValue() == Level.OFF.intValue() || record.getLevel().intValue() == AcsLogLevel.OFF.intValue()) { throw new IllegalArgumentException( "Level OFF must not be used for actual logging, but only for level filtering."); } StopWatch sw_all = null; if (PROFILE) { sw_all = new StopWatch(null); } // Level could be null and must then be inherited from the ancestor loggers, // e.g. during JDK shutdown when the log level is nulled by the JDK LogManager Logger loggerWithLevel = this; while (loggerWithLevel != null && loggerWithLevel.getLevel() == null && loggerWithLevel.getParent() != null) { loggerWithLevel = loggerWithLevel.getParent(); } int levelValue = -1; if (loggerWithLevel.getLevel() == null) { // HSO 2007-09-05: With ACS 6.0.4 the OMC uses this class (previously plain JDK logger) and has reported // that no level was found, which yielded a NPE. To be investigated further. // Probably #createUnconfiguredLogger was used without setting parent logger nor log level. // Just to be safe I add the necessary checks and warning message that improve over a NPE. if (!noLevelWarningPrinted) { System.out.println("Logger configuration error: no log level found for logger " + getLoggerName() + " or its ancestors. Will use Level.ALL instead."); noLevelWarningPrinted = true; } // @TODO: decide if resorting to ALL is desirable, or to use schema defaults, INFO, etc levelValue = Level.ALL.intValue(); } else { // level is fine, reset the flag to print the error message again when log level is missing. noLevelWarningPrinted = false; levelValue = loggerWithLevel.getLevel().intValue(); } // filter by log level to avoid unnecessary retrieval of context data. // The same check will be repeated by the base class implementation of this method that gets called afterwards. if (record.getLevel().intValue() < levelValue || levelValue == offValue) { return; } // modify the logger name if necessary if (loggerName != null) { record.setLoggerName(loggerName); } // check if this record already has the context data attached which ACS needs but the JDK logging API does not provide LogParameterUtil paramUtil = new LogParameterUtil(record); Map<String, Object> specialProperties = paramUtil.extractSpecialPropertiesMap(); if (specialProperties == null) { // we prepend the special properties map to the other parameters specialProperties = LogParameterUtil.createPropertiesMap(); List<Object> paramList = paramUtil.getNonSpecialPropertiesMapParameters(); paramList.add(0, specialProperties); record.setParameters(paramList.toArray()); String threadName = Thread.currentThread().getName(); specialProperties.put(LogParameterUtil.PARAM_THREAD_NAME, threadName); specialProperties.put(LogParameterUtil.PARAM_PROCESSNAME, this.processName); specialProperties.put(LogParameterUtil.PARAM_SOURCEOBJECT, this.sourceObject); // Get the stack trace StackTraceElement stack[] = (new Throwable()).getStackTrace(); // search for the first frame before the "Logger" class. int ix = 0; boolean foundNonLogFrame = false; while (ix < stack.length) { StackTraceElement frame = stack[ix]; String cname = frame.getClassName(); if (!foundNonLogFrame && !loggerClassNames.contains(cname)) { // We've found the relevant frame. record.setSourceClassName(cname); record.setSourceMethodName(frame.getMethodName()); int lineNumber = frame.getLineNumber(); specialProperties.put(LogParameterUtil.PARAM_LINE, Long.valueOf(lineNumber)); foundNonLogFrame = true; if (this.callStacksToBeIgnored.isEmpty()) { break; // performance optimization: avoid checking all "higher" stack frames } } if (foundNonLogFrame) { if (callStacksToBeIgnored.contains(concatenateIgnoreLogData(cname, frame.getMethodName()))) { //System.out.println("Won't log record with message " + record.getMessage()); return; } } ix++; } // We haven't found a suitable frame, so just punt. This is // OK as we are only committed to making a "best effort" here. } StopWatch sw_afterAcsLogger = null; if (PROFILE) { sw_afterAcsLogger = sw_all.createStopWatchForSubtask("afterAcsLogger"); LogParameterUtil logParamUtil = new LogParameterUtil(record); logParamUtil.setStopWatch(sw_afterAcsLogger); } // Let the delegate or Logger base class handle the rest. if (delegate != null) { delegate.log(record); } else { super.log(record); } if (PROFILE) { sw_afterAcsLogger.stop(); sw_all.stop(); long elapsedNanos = sw_all.getLapTimeNanos(); if (profileSlowestCallStopWatch == null || profileSlowestCallStopWatch.getLapTimeNanos() < elapsedNanos) { profileSlowestCallStopWatch = sw_all; } profileLogTimeStats.addValue(elapsedNanos); if (profileLogTimeStats.getN() >= profileStatSize) { String msg = "Local logging times in ms for the last " + profileStatSize + " logs: "; msg += "mean=" + profileMillisecFormatter.format(profileLogTimeStats.getMean() * 1E-6); msg += ", median=" + profileMillisecFormatter.format(profileLogTimeStats.getPercentile(50) * 1E-6); msg += ", stdev=" + profileMillisecFormatter.format(profileLogTimeStats.getStandardDeviation() * 1E-6); msg += "; details of slowest log (from "; msg += IsoDateFormat.formatDate(profileSlowestCallStopWatch.getStartTime()) + "): "; msg += profileSlowestCallStopWatch.getSubtaskDetails(); System.out.println(msg); profileSlowestCallStopWatch = null; profileLogTimeStats.clear(); } } }
From source file:de.uni_koblenz.jgralab.utilities.rsa.Rsa2Tg.java
/** * Processes an XMI-file to a TG-file as schema or a schema in a grUML * graph. For all command line options see * {@link Rsa2Tg#processCommandLineOptions(String[])}. * // ww w.j av a2s .co m * @param args * {@link String} array of command line options. * @throws IOException */ public static void main(String[] args) throws IOException { System.out.println("RSA to DHHTG"); System.out.println("========="); JGraLab.setLogLevel(Level.OFF); // Retrieving all command line options CommandLine cli = processCommandLineOptions(args); assert cli != null : "No CommandLine object has been generated!"; // All XMI input files File input = new File(cli.getOptionValue('i')); Rsa2Tg r = new Rsa2Tg(); r.setUseFromRole(cli.hasOption(OPTION_USE_ROLE_NAME)); r.setRemoveUnusedDomains(cli.hasOption(OPTION_REMOVE_UNUSED_DOMAINS)); r.setKeepEmptyPackages(cli.hasOption(OPTION_KEEP_EMPTY_PACKAGES)); r.setUseNavigability(cli.hasOption(OPTION_USE_NAVIGABILITY)); // apply options r.setFilenameSchema(cli.getOptionValue(OPTION_FILENAME_SCHEMA)); r.setFilenameSchemaGraph(cli.getOptionValue(OPTION_FILENAME_SCHEMA_GRAPH)); r.setFilenameDot(cli.getOptionValue(OPTION_FILENAME_DOT)); r.setFilenameValidation(cli.getOptionValue(OPTION_FILENAME_VALIDATION)); // If no output option is selected, Rsa2Tg will write at least the // schema file. boolean noOutputOptionSelected = !cli.hasOption(OPTION_FILENAME_SCHEMA) && !cli.hasOption(OPTION_FILENAME_SCHEMA_GRAPH) && !cli.hasOption(OPTION_FILENAME_DOT) && !cli.hasOption(OPTION_FILENAME_VALIDATION); if (noOutputOptionSelected) { System.out.println( "No output option has been selected. " + "A DHHTG-file for the Schema will be written."); // filename have to be set r.setFilenameSchema(createFilename(input)); } try { System.out.println("processing: " + input.getPath() + "\n"); r.process(input.getPath()); } catch (Exception e) { System.err.println("An Exception occured while processing " + input + "."); System.err.println(e.getMessage()); e.printStackTrace(); } System.out.println("Fini."); }
From source file:de.ppi.selenium.browser.DefaultWebDriverFactory.java
@Override public DesiredCapabilities createCapabilities(Map<String, String> options) throws Exception { ClientProperties properties = new ClientProperties(options.get(CLIENT_PROPERTIES_KEY)); final String browser = properties.getBrowser(); if (properties.isUseGrid()) { DesiredCapabilities capabilities = null; if (properties.getGridUrl().length() == 0) { throw new Exception("You must provide 'grid.url' to use Selenium Grid in client property file"); }/*from w ww . ja v a 2 s .c o m*/ if (browser.length() == 0) { throw new Exception("You must provide 'browser' to use Selenium Grid in client property file"); } if (properties.getGridPlatform().length() == 0) { throw new Exception( "You must provide 'grid.platform' to use Selenium Grid in client property file"); } if (browser.equalsIgnoreCase("ie") || browser.equalsIgnoreCase("iexplore") || browser.equalsIgnoreCase("*iexplore")) { capabilities = DesiredCapabilities.internetExplorer(); } else if ((browser.equalsIgnoreCase("firefox") || browser.equalsIgnoreCase("*firefox"))) { capabilities = DesiredCapabilities.firefox(); } else if (browser.equalsIgnoreCase("chrome")) { capabilities = DesiredCapabilities.chrome(); } else if (browser.equalsIgnoreCase("safari")) { capabilities = DesiredCapabilities.safari(); } else if (browser.equalsIgnoreCase("opera")) { capabilities = DesiredCapabilities.operaBlink(); } else if (browser.equalsIgnoreCase("android")) { capabilities = DesiredCapabilities.android(); } else if (browser.equalsIgnoreCase("ipad")) { capabilities = DesiredCapabilities.ipad(); } else if (browser.equalsIgnoreCase("iphone")) { capabilities = DesiredCapabilities.iphone(); } else if (browser.equalsIgnoreCase("phantomjs")) { capabilities = DesiredCapabilities.phantomjs(); } else { log.fatal("Unsupported browser: " + browser + " Please refer to documentation for supported browsers."); } capabilities.setVersion(properties.getBrowserVersion()); String platform = properties.getGridPlatform(); if (platform != null && platform.length() > 0) { capabilities.setCapability("platform", platform); } else { // Default to Windows 7 capabilities.setCapability("platform", "Windows 7"); } // Set Proxy String proxyStr = properties.getProxy(); String proxyHttps = properties.getProxyHttps(); Proxy proxy = null; if (proxyStr != null && !proxyStr.equals("")) { proxy = new Proxy(); proxy.setHttpProxy(proxyStr); } if (proxyHttps != null && !proxyHttps.equals("")) { if (proxy == null) { proxy = new Proxy(); } proxy.setSslProxy(proxyHttps); } if (proxy != null) { capabilities.setCapability(CapabilityType.PROXY, proxy); } // preparing data for session name String computerName = null; try { computerName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.warn("error getting the computer-name", e); } capabilities.setCapability("name", "WebBrowser client=" + properties.getClient() + "; started from " + computerName); String gridProperties = properties.getGridProperties(); if (gridProperties != null && gridProperties.length() > 0) { String[] gridPropertiesSlpitted = gridProperties.split(" "); for (String gridPropertiesSlpittedCurrent : gridPropertiesSlpitted) { if (gridPropertiesSlpittedCurrent != null && gridPropertiesSlpittedCurrent.length() > 0) { String[] propertyNameAndValue = gridPropertiesSlpittedCurrent.split("="); if (propertyNameAndValue.length == 2) { capabilities.setCapability(propertyNameAndValue[0], propertyNameAndValue[1]); } } } } return capabilities; } else { log.debug("browser [" + browser + "]"); // Turning off all console logs using java.util.logging Handler[] h = java.util.logging.LogManager.getLogManager().getLogger("").getHandlers(); for (int i = 0; i < h.length; i++) { if (h[i] instanceof ConsoleHandler) { h[i].setLevel(Level.OFF); } } String proxyProperty = properties.getProxy(); DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); if (proxyProperty != null) { Proxy proxy = new Proxy(); proxy.setHttpProxy(proxyProperty).setFtpProxy(proxyProperty).setSslProxy(proxyProperty); desiredCapabilities = new DesiredCapabilities(); if (browser != null && browser.equalsIgnoreCase("chrome")) { // chrome way of proxy initialization desiredCapabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://" + proxy)); } else { // ff and ie way of proxy initialization desiredCapabilities.setCapability(CapabilityType.PROXY, proxy); } } if (properties.getDownloadFolder() != null && properties.getDownloadFolder().length() > 0) { // '0' means to download to the desktop, '1' means to download // to the default "Downloads" directory, '2' means to use the // directory you specify in "browser.download.dir" desiredCapabilities.setCapability("browser.download.folderList", Integer.valueOf(2)); desiredCapabilities.setCapability("browser.download.dir", System.getProperty("user.dir") + System.getProperty("file.separator") + properties.getDownloadFolder()); desiredCapabilities.setCapability("browser.helperApps.neverAsk.saveToDisk", "text/csv, application/octet-stream, application/pdf, application/vnd.fdf, application/x-msdos-program, application/x-unknown-application-octet-stream, application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel, application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip,application/x-stuffit,application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar, video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff"); desiredCapabilities.setCapability("browser.helperApps.alwaysAsk.force", false); desiredCapabilities.setCapability("browser.download.manager.showWhenStarting", false); } return desiredCapabilities; } }