def detect_pip_exe(): """TODO: Docstring for detect_pip_exe. :returns: TODO """ from pybombs.config_manager import config_manager if vcompare('>=', config_manager.get_python_version(), '3'): default_pip = 'pip3' else: default_pip = 'pip2' if sysutils.which(default_pip) is not None: return default_pip if sysutils.which('pip') is not None: return 'pip' return None
def detect_pip_exe(): """ Returns the path to the pip version used. Factors in the available Python version. """ from pybombs.config_manager import config_manager if vcompare('>=', config_manager.get_python_version(), '3'): default_pip = 'pip3' else: default_pip = 'pip2' if sysutils.which(default_pip) is not None: return default_pip if sysutils.which('pip') is not None: return 'pip' return None
def fetch_url(self, url, dest, dirname, args=None): """ git clone """ git_version = get_git_version() self.log.debug("We have git version %s", git_version) url, args = parse_git_url(url, args or {}) self.log.debug("Using url - {0}".format(url)) git_cmd = ['git', 'clone', url, dirname] if args.get('gitargs'): for arg in args.get('gitargs').split(): git_cmd.append(arg) if self.cfg.get("git-cache", False): from pybombs import gitcache_manager gcm = gitcache_manager.GitCacheManager(self.cfg.get("git-cache")) self.log.debug("Adding remote into git ref") gcm.add_remote(dirname, url, True) git_cmd.append( '--reference-if-able' if vcompare(">=", git_version, "2.11") else '--reference' ) git_cmd.append(self.cfg.get("git-cache")) if args.get('gitbranch'): git_cmd.append('-b') git_cmd.append(args.get('gitbranch')) o_proc = None subproc.monitor_process( args=git_cmd, o_proc=o_proc, throw_ex=True, throw=True, ) # If we have a specific revision, checkout that if args.get('gitrev'): cwd = os.getcwd() src_dir = os.path.join(dest, dirname) self.log.trace("Switching cwd to: {0}".format(src_dir)) os.chdir(src_dir) git_co_cmd = ["git", "checkout", "--force", args.get('gitrev')] subproc.monitor_process( args=git_co_cmd, o_proc=o_proc, throw_ex=True, ) self.log.trace("Switching cwd to: {0}".format(cwd)) os.chdir(cwd) return True
def fetch_url(self, url, dest, dirname, args=None): """ git clone """ git_version = get_git_version() self.log.debug("We have git version %s", git_version) url, args = parse_git_url(url, args or {}) self.log.debug("Using url - {0}".format(url)) git_cmd = ['git', 'clone', url, dirname] if args.get('gitargs'): for arg in args.get('gitargs').split(): git_cmd.append(arg) if self.cfg.get("git-cache", False): from pybombs import gitcache_manager gcm = gitcache_manager.GitCacheManager(self.cfg.get("git-cache")) self.log.debug("Adding remote into git ref") gcm.add_remote(dirname, url, True) git_cmd.append( '--reference-if-able' if vcompare(">=", git_version, "2.11") else '--reference' ) git_cmd.append(self.cfg.get("git-cache")) if args.get('gitbranch'): git_cmd.append('-b') git_cmd.append(args.get('gitbranch')) o_proc = None subproc.monitor_process( args=git_cmd, o_proc=o_proc, throw_ex=True, throw=True, ) # If we have a specific revision, checkout that if args.get('gitrev'): cwd = os.getcwd() src_dir = os.path.join(dest, dirname) self.log.obnoxious("Switching cwd to: {0}".format(src_dir)) os.chdir(src_dir) git_co_cmd = ["git", "checkout", "--force", args.get('gitrev')] subproc.monitor_process( args=git_co_cmd, o_proc=o_proc, throw_ex=True, ) self.log.obnoxious("Switching cwd to: {0}".format(cwd)) os.chdir(cwd) return True