Beispiel #1
0
  public static void logFile(String file, String project, boolean isWrite) {
    final String[] cmds = buildCliCommands(file, project, isWrite);

    if (DEBUG) WakaTime.log(cmds.toString());

    Runnable r =
        new Runnable() {
          public void run() {
            try {
              Process proc = Runtime.getRuntime().exec(cmds);
              if (DEBUG) {
                BufferedReader stdInput =
                    new BufferedReader(new InputStreamReader(proc.getInputStream()));
                BufferedReader stdError =
                    new BufferedReader(new InputStreamReader(proc.getErrorStream()));
                proc.waitFor();
                String s;
                while ((s = stdInput.readLine()) != null) {
                  WakaTime.log(s);
                }
                while ((s = stdError.readLine()) != null) {
                  WakaTime.log(s);
                }
                WakaTime.log("Command finished with return value: " + proc.exitValue());
              }
            } catch (Exception e) {
              WakaTime.error("Error", e);
            }
          }
        };
    new Thread(r).start();
  }
Beispiel #2
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext context) throws Exception {
    logInstance = getLog();
    WakaTime.log("Initializing WakaTime plugin (https://wakatime.com) v" + VERSION);

    super.start(context);
    plugin = this;

    editorListener = new CustomEditorListener();
  }
Beispiel #3
0
 public static String[] buildCliCommands(String file, String project, boolean isWrite) {
   ArrayList<String> cmds = new ArrayList<String>();
   cmds.add(Dependencies.getPythonLocation());
   cmds.add(WakaTime.getWakaTimeCLI());
   cmds.add("--file");
   cmds.add(WakaTime.fixFilePath(file));
   cmds.add("--plugin");
   cmds.add("eclipse/" + ECLIPSE_VERSION + " eclipse-wakatime/" + VERSION);
   if (project != null) {
     cmds.add("--project");
     cmds.add(project);
   }
   if (isWrite) cmds.add("--write");
   if (DEBUG) {
     WakaTime.log(cmds.toString());
     cmds.add("--verbose");
   }
   return cmds.toArray(new String[cmds.size()]);
 }