Package com.opera.core.systems.runner

Examples of com.opera.core.systems.runner.OperaRunnerException


    // on users system if it's not there or outdated
    URL bundledLauncher =
        OperaLaunchers.class.getClassLoader().getResource("launchers/" + LAUNCHER_NAME);

    if (bundledLauncher == null) {
      throw new OperaRunnerException("Not able to locate bundled launcher: " + LAUNCHER_NAME);
    }

    File launcher = settings.getLauncher();
    try {
      if (launcher.getCanonicalPath().equals(LAUNCHER_DEFAULT_LOCATION.getCanonicalPath()) &&
          (!launcher.exists() || isLauncherOutdated(launcher))) {
        extractLauncher(bundledLauncher, launcher);
      }
    } catch (IOException e) {
      throw new OperaRunnerException(e);
    }

    if (!launcher.canExecute()) {
      if (!launcher.setExecutable(true)) {
        throw new OperaRunnerException("Unable to make launcher executable: " + launcher.getPath());
      }
    }

    // Create list of arguments for launcher binary
    arguments = buildArguments(settings, launcherPort);
View Full Code Here


  private void init() {
    try {
      binary = new OperaLauncherBinary(settings.getLauncher().getCanonicalPath(),
                                       Iterables.toArray(arguments, String.class));
    } catch (IOException e) {
      throw new OperaRunnerException("Unable to start launcher: " + e.getMessage());
    }

    logger.fine("Waiting for launcher connection on port " + launcherPort);

    ServerSocket listenerServer = null;
    try {
      // Setup listener server
      listenerServer = new ServerSocket(launcherPort);
      // TODO(andreastt): Unsafe int cast
      listenerServer.setSoTimeout((int) OperaIntervals.LAUNCHER_CONNECT_TIMEOUT.getMs());

      // Try to connect
      protocol = new OperaLauncherProtocol(listenerServer.accept());

      // We did it!
      logger.fine("Connected with launcher on port " + launcherPort);

      // Do the handshake!
      LauncherHandshakeRequest.Builder request = LauncherHandshakeRequest.newBuilder();
      ResponseEncapsulation res = protocol.sendRequest(
          MessageType.MSG_HELLO, request.build().toByteArray());

      // Are we happy?
      if (res.isSuccess()) {
        logger.finer("Got launcher handshake: " + res.getResponse().toString());
      } else {
        throw new OperaRunnerException(
            "Did not get launcher handshake: " + res.getResponse().toString());
      }
    } catch (SocketTimeoutException e) {
      throw new OperaRunnerException("Timeout waiting for launcher to connect on port " +
                                     launcherPort, e);
    } catch (IOException e) {
      throw new OperaRunnerException("Unable to listen to launcher port " + launcherPort, e);
    } finally {
      Closeables.closeQuietly(listenerServer);
    }
  }
View Full Code Here

        throw new IOException(
            "Opera exited immediately; possibly incorrect arguments?  Command: " +
            binary.getCommands());
      }
    } catch (IOException e) {
      throw new OperaRunnerException("Could not start Opera: " + e.getMessage());
    }
  }
View Full Code Here

      if (handleStatusMessage(res.getResponse()) == StatusType.RUNNING) {
        throw new IOException("launcher unable to stop binary");
      }
    } catch (IOException e) {
      throw new OperaRunnerException("Could not stop Opera: " + e.getMessage());
    }
  }
View Full Code Here

    try {
      // Then shutdown the protocol connection
      protocol.shutdown();
    } catch (IOException e) {
      throw new OperaRunnerException("Unable to shut down launcher", e);
    } finally {
      binary.shutdown();
      protocol = null;
      binary = null;
    }
View Full Code Here

      if (response.hasBlank()) {
        blank = response.getBlank();
      }
    } catch (SocketTimeoutException e) {
      throw new OperaRunnerException("Could not get screenshot from launcher", e);
    } catch (IOException e) {
      throw new OperaRunnerException("Could not get screenshot from launcher", e);
    }

    ScreenCaptureReply.Builder builder = ScreenCaptureReply.builder();
    builder.setMD5(resultMd5);
    builder.setPNG(resultBytes);
View Full Code Here

      is = sourceLauncher.openStream();
      os = new FileOutputStream(targetLauncher);

      ByteStreams.copy(is, os);
    } catch (IOException e) {
      throw new OperaRunnerException("Cannot write file to disk: " + e.getMessage());
    } finally {
      Closeables.closeQuietly(is);
      Closeables.closeQuietly(os);
    }
View Full Code Here

  private boolean isLauncherOutdated(File launcher) {
    try {
      return !MD5.of(launcher).equals(LAUNCHER_CHECKSUMS.get(launcher.getName()));
    } catch (IOException e) {
      throw new OperaRunnerException("Unable to open stream or file: " + e.getMessage());
    }
  }
View Full Code Here

    }
  }

  private void assertLauncherAlive() {
    if (!isLauncherRunning()) {
      throw new OperaRunnerException("launcher was shutdown");
    }
  }
View Full Code Here

      if (!startedProperly) {
        throw new IOException("Opera exited immediately; possibly incorrect arguments?  Command: "
                              + process);
      }
    } catch (IOException e) {
      throw new OperaRunnerException("Could not start Opera: " + e.getMessage());
    } finally {
      lock.unlock();
    }
  }
View Full Code Here

TOP

Related Classes of com.opera.core.systems.runner.OperaRunnerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.