Exemple #1
0
  public Snitcher() {

    view = new SnitcherView(this);
    view.createAndShowGUI();

    readSettingsFromXML();

    addProjectsToView();

    view.setVisible(true);

    initializeVoice();

    timer.start();

    monitor.updateStatus();
  }
Exemple #2
0
  public void destroy() {
    System.out.println("Destroy called!");
    view.dispose();

    running = false;

    voice.deallocate();

    timer.stop();

    arduino.close();
  }
Exemple #3
0
  public void start() {
    while (running) {
      int offset = 0;

      boolean buildInterrupted = false;
      boolean buildFailed = false;
      boolean building = false;

      List<String> blames = new ArrayList<String>();
      String sayString = "";

      try {
        for (JenkinsProject project : monitor.projects) {
          if (project.isBuilding()) {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILDING);
            building = true;
          } else if (project.getStatus().equals("SUCCESS")) {
            // arduino.setChannelToState(offset,
            // / ProjectState.BUILD_SUCCEEDED);
          } else if (project.getStatus().equals("ABORTED")) {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILD_INTERRUPTED);
            buildInterrupted = true;
          } else {
            // arduino.setChannelToState(offset,
            // ProjectState.BUILD_FAILED);
            buildFailed = true;

            String person = project.getLastUser();

            if ((!person.equals("anonymous")) && (!blames.contains(person))) {
              blames.add(person);
            }
          }

          if (project.mustNotify()) {

            if (sayString.equals("")) {
              sayString = "Attention please! ";
            }

            String notifyString = project.getNotifyString();
            sayString += notifyString + "! ";

            project.setNotified(true);
          }

          offset += 1;
        }

        ProjectState serverState = ProjectState.BUILD_SUCCEEDED;
        if (buildFailed) {
          serverState = ProjectState.BUILD_FAILED;
        }

        if (!sayString.equals("")) {
          say(sayString);
        }

        view.setBlames(blames);

        arduino.setChannelToState(0, serverState);

      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      arduino.sendStatus();
      // view.update();

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemple #4
0
 private void addProjectsToView() {
   for (JenkinsProject project : monitor.projects) {
     System.out.println("Adding: " + project.getName());
     view.addProject(project);
   }
 }