Beispiel #1
0
  protected boolean processCmd(MyCommandOptions co) {
    String[] args = co.getArgArray();
    String cmd = co.getCommand();
    if (args.length < 1) {
      usage();
      return false;
    }
    if (!getHedwigCommands().containsKey(cmd)) {
      usage();
      return false;
    }

    LOG.debug("Processing {}", cmd);

    MyCommand myCommand = myCommands.get(cmd);
    if (myCommand == null) {
      System.err.println("No Command Processor found for command " + cmd);
      usage();
      return false;
    }

    long startTime = MathUtils.now();
    boolean success = false;
    try {
      success = myCommand.runCmd(args);
    } catch (Exception e) {
      e.printStackTrace();
      success = false;
    }
    long elapsedTime = MathUtils.now() - startTime;
    if (inConsole) {
      if (success) {
        System.out.println("Finished " + ((double) elapsedTime / 1000) + " s.");
      } else {
        COMMAND c = getHedwigCommands().get(cmd);
        if (c != null) {
          c.printUsage();
        }
      }
    }
    return success;
  }
Beispiel #2
0
 public void run() {
   try {
     String mc_wol = System.getProperty("user.dir") + File.separator + "mc-wol.exe ",
         hostName = computer.getHostName(),
         macAddr = computer.getMacAddr();
     if (!cmd.isConnect(hostName) && macAddr != null && !macAddr.equals(""))
       Runtime.getRuntime().exec(mc_wol + macAddr);
     else System.out.println(hostName + " : MAC Address is null.");
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
 }
Beispiel #3
0
 public void actionPerformed(ActionEvent event) {
   setSelected(getSelected(event.getSource()));
   super.actionPerformed(event);
 }