PipWrapper { public Set<PipInstalledPackage> getFreezePackages() throws ProcessWrapperException, IOException, InterruptedException { final StopWatch sw = new StopWatch("pip freeze").start(); Set<PipInstalledPackage> packages = null; ProcessWrapper pw = new ProcessWrapper().setCommand(this.pathToPip, "freeze").setPath(logDir); final Thread t = new Thread(pw, "pip"); t.start(); t.join(); if (pw.terminatedWithSuccess()) { packages = this.parsePipFreezeOutput(pw.getOutFile()); log.info("Found [" + packages.size() + "] pip packages:"); for (PipInstalledPackage pack : packages) log.info(" " + pack); final ExecutorService pool = Executors.newFixedThreadPool(ThreadUtil.getNoThreads(2)); final Set<Future<PipInstalledPackage>> futures = new HashSet<Future<PipInstalledPackage>>(); for (PipInstalledPackage pack : packages) { futures.add(pool.submit(new PipShow(pack))); futures.add(pool.submit(new PipDownload(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"); } } sw.stop(); return packages; } PipWrapper();  PipWrapper(Path _path_to_pip, Path _log_dir); boolean isAvailable(); Set<PipInstalledPackage> installPackages(Path _project); Set<PipInstalledPackage> getFreezePackages(); Set<PipInstalledPackage> getListPackages();  }
@Test @Category(Slow.class) public void testGetFreezePackages() throws ProcessWrapperException, FileAnalysisException { VulasConfiguration.getGlobal().setProperty(ThreadUtil.NO_OF_THREADS, "AUTO"); final PipWrapper pip = new PipWrapper(); Set<PipInstalledPackage> packs = null; try { packs = pip.getFreezePackages(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } assertTrue(packs.size() > 0); for (PipInstalledPackage p : packs) { System.out.println(p); } }