Ejemplo n.º 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();
  }
Ejemplo n.º 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();
  }
Ejemplo n.º 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()]);
 }
Ejemplo n.º 4
0
 public static String getWakaTimeCLI() {
   Bundle bundle = Platform.getBundle("com.wakatime.eclipse.plugin");
   URL url = bundle.getEntry("/");
   URL rootURL = null;
   try {
     rootURL = FileLocator.toFileURL(url);
   } catch (Exception e) {
     WakaTime.error("Error", e);
   }
   if (rootURL == null) return null;
   File script =
       new File(
           Dependencies.combinePaths(
               rootURL.getPath(), "dependencies", "wakatime-master", "wakatime", "cli.py"));
   return script.getAbsolutePath();
 }
Ejemplo n.º 5
0
 public static void error(String msg, Exception e) {
   WakaTime.logMessage(msg, Status.ERROR, e);
 }
Ejemplo n.º 6
0
 public static void error(String msg) {
   WakaTime.logMessage(msg, Status.ERROR, null);
 }
Ejemplo n.º 7
0
 public static void log(String msg) {
   WakaTime.logMessage(msg, Status.INFO, null);
 }