test_class.file: lang-python/src/test/java/org/eclipse/steady/python/pip/PipWrapperTest.java
test_class.identifier: PipWrapperTest
test_case.body: @Test
    public void testGetListPackages() throws ProcessWrapperException, FileAnalysisException {
      VulasConfiguration.getGlobal().setProperty(ThreadUtil.NO_OF_THREADS, "AUTO");
      final PipWrapper pip = new PipWrapper();
      Set<PipInstalledPackage> packs = null;
      try {
        packs = pip.getListPackages();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      assertTrue(packs.size() > 0);
    }
test_case.class_method_signature: PipWrapperTest.testGetListPackages()
test_case.full_signature: @Test public void testGetListPackages()
test_case.identifier: testGetListPackages
test_case.invocations: setProperty getGlobal getListPackages printStackTrace printStackTrace assertTrue size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetListPackages()
focal_class.declarator: log = org.apache.logging.log4j.LogManager.getLogger()
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = org.apache.logging.log4j.LogManager.getLogger();
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: DOWNLOAD_PATTERN = Pattern.compile("^\\s*Downloading\\s*(http\\S*).*$")
focal_class.modifier: static final
focal_class.original_string: static final Pattern DOWNLOAD_PATTERN = Pattern.compile("^\\s*Downloading\\s*(http\\S*).*$");
focal_class.type: Pattern
focal_class.var_name: DOWNLOAD_PATTERN
focal_class.declarator: SAVED_PATTERN_1 =
        Pattern.compile("^\\s*File was already downloaded\\s*(.*)$")
focal_class.modifier: static final
focal_class.original_string: static final Pattern SAVED_PATTERN_1 =
        Pattern.compile("^\\s*File was already downloaded\\s*(.*)$");
focal_class.type: Pattern
focal_class.var_name: SAVED_PATTERN_1
focal_class.declarator: SAVED_PATTERN_2 = Pattern.compile("^\\s*Saved\\s*(.*)$")
focal_class.modifier: static final
focal_class.original_string: static final Pattern SAVED_PATTERN_2 = Pattern.compile("^\\s*Saved\\s*(.*)$");
focal_class.type: Pattern
focal_class.var_name: SAVED_PATTERN_2
focal_class.declarator: PACK_PATTERN_REGEX = ".*<pack>-<version>.*"
focal_class.modifier: static final
focal_class.original_string: static final String PACK_PATTERN_REGEX = ".*<pack>-<version>.*";
focal_class.type: String
focal_class.var_name: PACK_PATTERN_REGEX
focal_class.declarator: pathToPip = null
focal_class.modifier: private
focal_class.original_string: private Path pathToPip = null;
focal_class.type: Path
focal_class.var_name: pathToPip
focal_class.declarator: logDir = null
focal_class.modifier: private
focal_class.original_string: private Path logDir = null;
focal_class.type: Path
focal_class.var_name: logDir
focal_class.declarator: ignorePacks = new StringList()
focal_class.modifier: private
focal_class.original_string: private StringList ignorePacks = new StringList();
focal_class.type: StringList
focal_class.var_name: ignorePacks
focal_class.file: lang-python/src/main/java/org/eclipse/steady/python/pip/PipWrapper.java
focal_class.identifier: PipWrapper
focal_class.class_method_signature: PipWrapper.PipWrapper()
focal_class.full_signature: public  PipWrapper()
focal_class.identifier: PipWrapper
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  PipWrapper()
focal_class.class_method_signature: PipWrapper.PipWrapper(Path _path_to_pip, Path _log_dir)
focal_class.full_signature: public  PipWrapper(Path _path_to_pip, Path _log_dir)
focal_class.identifier: PipWrapper
focal_class.modifiers: public
focal_class.parameters: (Path _path_to_pip, Path _log_dir)
focal_class.signature:  PipWrapper(Path _path_to_pip, Path _log_dir)
focal_class.class_method_signature: PipWrapper.ignorePackage(String _p)
focal_class.full_signature: private boolean ignorePackage(String _p)
focal_class.identifier: ignorePackage
focal_class.modifiers: private
focal_class.parameters: (String _p)
focal_class.return: boolean
focal_class.signature: boolean ignorePackage(String _p)
focal_class.class_method_signature: PipWrapper.isAvailable()
focal_class.full_signature: public boolean isAvailable()
focal_class.identifier: isAvailable
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isAvailable()
focal_class.class_method_signature: PipWrapper.installPackages(Path _project)
focal_class.full_signature: public Set<PipInstalledPackage> installPackages(Path _project)
focal_class.identifier: installPackages
focal_class.modifiers: public
focal_class.parameters: (Path _project)
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> installPackages(Path _project)
focal_class.class_method_signature: PipWrapper.getFreezePackages()
focal_class.full_signature: public Set<PipInstalledPackage> getFreezePackages()
focal_class.identifier: getFreezePackages
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> getFreezePackages()
focal_class.class_method_signature: PipWrapper.parsePipFreezeOutput(Path _file)
focal_class.full_signature: private Set<PipInstalledPackage> parsePipFreezeOutput(Path _file)
focal_class.identifier: parsePipFreezeOutput
focal_class.modifiers: private
focal_class.parameters: (Path _file)
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> parsePipFreezeOutput(Path _file)
focal_class.class_method_signature: PipWrapper.getListPackages()
focal_class.full_signature: public Set<PipInstalledPackage> getListPackages()
focal_class.identifier: getListPackages
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> getListPackages()
focal_class.class_method_signature: PipWrapper.parsePipListOutput(Path _file)
focal_class.full_signature: private Set<PipInstalledPackage> parsePipListOutput(Path _file)
focal_class.identifier: parsePipListOutput
focal_class.modifiers: private
focal_class.parameters: (Path _file)
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> parsePipListOutput(Path _file)
focal_class.class_method_signature: PipWrapper.deserializePipListOutput(Path _file)
focal_class.full_signature: private Set<PipInstalledPackage> deserializePipListOutput(Path _file)
focal_class.identifier: deserializePipListOutput
focal_class.modifiers: private
focal_class.parameters: (Path _file)
focal_class.return: Set<PipInstalledPackage>
focal_class.signature: Set<PipInstalledPackage> deserializePipListOutput(Path _file)
focal_class.class_method_signature: PipWrapper.parsePipShowOutput(Path _file)
focal_class.full_signature: private Map<String, String> parsePipShowOutput(Path _file)
focal_class.identifier: parsePipShowOutput
focal_class.modifiers: private
focal_class.parameters: (Path _file)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> parsePipShowOutput(Path _file)
focal_class.class_method_signature: PipWrapper.searchDownloadInfo(Set<PipInstalledPackage> _packs, String _out)
focal_class.full_signature:  void searchDownloadInfo(Set<PipInstalledPackage> _packs, String _out)
focal_class.identifier: searchDownloadInfo
focal_class.parameters: (Set<PipInstalledPackage> _packs, String _out)
focal_class.return: void
focal_class.signature: void searchDownloadInfo(Set<PipInstalledPackage> _packs, String _out)
focal_class.class_method_signature: PipWrapper.searchDownloadInfo(PipInstalledPackage _p, String _out)
focal_class.full_signature: private void searchDownloadInfo(PipInstalledPackage _p, String _out)
focal_class.identifier: searchDownloadInfo
focal_class.modifiers: private
focal_class.parameters: (PipInstalledPackage _p, String _out)
focal_class.return: void
focal_class.signature: void searchDownloadInfo(PipInstalledPackage _p, String _out)
focal_method.body: public Set<PipInstalledPackage> getListPackages()
        throws ProcessWrapperException, IOException, InterruptedException {
      final StopWatch sw = new StopWatch("pip list").start();
  
      // Try legacy format
      ProcessWrapper pw =
          new ProcessWrapper()
              .setCommand(this.pathToPip, "list", "--format", "legacy")
              .setPath(logDir);
      Thread t = new Thread(pw, "pip");
      t.start();
      t.join();
  
      Set<PipInstalledPackage> packages = null;
      if (pw.terminatedWithSuccess()) {
        packages = this.parsePipListOutput(pw.getOutFile());
      }
      // Try JSON format
      else {
        log.info("Legacy format did not work, trying JSON format...");
        pw =
            new ProcessWrapper()
                .setCommand(this.pathToPip, "list", "--format", "json")
                .setPath(logDir);
        t = new Thread(pw, "pip");
        t.start();
        t.join();
        if (pw.terminatedWithSuccess()) packages = this.deserializePipListOutput(pw.getOutFile());
      }
  
      // Collect package details
      if (packages != null) {
        log.info("Found [" + packages.size() + "] pip packages:");
        for (PipInstalledPackage pack : packages) log.info("    " + pack);
  
        // Call pip show in separate threads
        final ExecutorService pool =
            Executors.newFixedThreadPool(ThreadUtil.getNoThreads(2)); // newSingleThreadExecutor();
        final Set<Future<PipInstalledPackage>> futures = new HashSet<Future<PipInstalledPackage>>();
        for (PipInstalledPackage pack : packages) {
          futures.add(pool.submit(new PipShow(pack)));
        }
        pool.shutdown();
        try {
          while (!pool.awaitTermination(10, TimeUnit.SECONDS)) {
            int done = 0;
            for (Future<PipInstalledPackage> f : futures) {
              if (f.isDone()) done++;
            }
            sw.lap("[" + done + "/" + futures.size() + "] pip jobs are done");
          }
        } catch (InterruptedException e) {
          PipWrapper.log.error("Interrupt exception");
        }
      } else {
        log.warn("No pip packages found with pip list");
      }
  
      sw.stop();
      return packages;
    }
focal_method.class_method_signature: PipWrapper.getListPackages()
focal_method.full_signature: public Set<PipInstalledPackage> getListPackages()
focal_method.identifier: getListPackages
focal_method.invocations: start setPath setCommand start join terminatedWithSuccess parsePipListOutput getOutFile info setPath setCommand start join terminatedWithSuccess deserializePipListOutput getOutFile info size info newFixedThreadPool getNoThreads add submit shutdown awaitTermination isDone lap size error warn stop
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: Set<PipInstalledPackage>
focal_method.signature: Set<PipInstalledPackage> getListPackages()