def _check_pip(self): cmdline = self.pip_cmd + ["--version"] try: exec_and_communicate(cmdline) except TaurusCalledProcessError as exc: self.log.debug(exc) raise TaurusInternalException( "pip module not found for interpreter %s" % self.interpreter)
def _get_installed(self): cmdline = self.pip_cmd + ["list"] out, _ = exec_and_communicate(cmdline) out = out.split('\n')[2:-1] return dict( zip([line.split(' ')[0] for line in out], [line.strip().split(' ')[-1] for line in out]))
def install(self): if not self.packages: self.log.debug("Nothing to install") return cmdline = self.pip_cmd + ["install", "-t", self.target_dir] for package in self.packages: version = self.versions.get(package, None) cmdline += [f"{package}=={version}"] if version else [package] cmdline += ["--upgrade"] self.log.debug("pip-installer cmdline: '%s'" % ' '.join(cmdline)) try: out, err = exec_and_communicate(cmdline) except TaurusCalledProcessError as exc: self.log.debug(exc) for line in exc.output.split('\n'): if line.startswith("ERROR"): self.log.error(" ".join(line.split(" ")[1:])) return if "Successfully installed" in out: self.log.info(out.split("\n")[-2]) for err_line in err.split("\n"): if err_line.startswith('WARNING'): self.log.warning(" ".join(err_line.split(" ")[1:])) if err_line.startswith('ERROR'): self.log.error(" ".join(err_line.split(" ")[1:])) self.log.debug("pip-installer stdout: \n%s" % out) if err: self.log.debug("pip-installer stderr:\n%s" % err)
def _install(self, packages): if not packages: self.log.debug("Nothing to install") return cmdline = self.pip_cmd + ["install", "-t", self.target_dir] cmdline += self.packages self.log.debug("pip-installer cmdline: '%s'" % ' '.join(cmdline)) out, err = exec_and_communicate(cmdline) if err: self.log.error("pip-installer stderr:\n%s" % err) self.log.debug("pip-installer stdout: \n%s" % out)
def check_if_installed(self): self.log.debug("Trying %s...", self.tool_name) cmd = [self.tool_path, '-list-avds'] try: output = exec_and_communicate(cmd) except CALL_PROBLEMS as exc: self.log.debug("Failed to check %s: %s", self.tool_name, exc) return False self.log.debug("%s output: %s", self.tool_name, output) return True
def _check_path(self, path): cmd = [path, '--version'] try: out, err = exec_and_communicate(cmd) except CALL_PROBLEMS as exc: self.log.debug("Failed to check %s: %s", self.tool_name, exc) return False if err: out += err self.log.debug("%s output: %s", self.tool_name, out) return True
def _missed(self, packages): # todo: add version handling cmdline = self.pip_cmd + ["list"] out, _ = exec_and_communicate(cmdline) list_of_installed = [ line.split(' ')[0] for line in out.split('\n')[2:-1] ] missed = [] for package in packages: if package not in list_of_installed: missed.append(package) return missed