當前位置: 首頁>>代碼示例>>Python>>正文


Python util.call_subprocess方法代碼示例

本文整理匯總了Python中pip.util.call_subprocess方法的典型用法代碼示例。如果您正苦於以下問題:Python util.call_subprocess方法的具體用法?Python util.call_subprocess怎麽用?Python util.call_subprocess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip.util的用法示例。


在下文中一共展示了util.call_subprocess方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: switch

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def switch(self, dest, url, rev_options):
        repo_config = os.path.join(dest, self.dirname, 'hgrc')
        config = ConfigParser.SafeConfigParser()
        try:
            config.read(repo_config)
            config.set('paths', 'default', url)
            config_file = open(repo_config, 'w')
            config.write(config_file)
            config_file.close()
        except (OSError, ConfigParser.NoSectionError):
            e = sys.exc_info()[1]
            logger.warn(
                'Could not switch Mercurial repository to %s: %s'
                % (url, e))
        else:
            call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:18,代碼來源:mercurial.py

示例2: obtain

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = [rev]
            rev_display = ' (to %s)' % rev
        else:
            rev_options = ['origin/master']
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest)))
            call_subprocess([self.cmd, 'clone', '-q', url, dest])
            #: repo may contain submodules
            self.update_submodules(dest)
            if rev:
                rev_options = self.check_rev_options(rev, dest, rev_options)
                # Only do a checkout if rev_options differs from HEAD
                if not self.get_revision(dest).startswith(rev_options[0]):
                    call_subprocess([self.cmd, 'checkout', '-q'] + rev_options, cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:20,代碼來源:git.py

示例3: get_refs

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def get_refs(self, location):
        """Return map of named refs (branches or tags) to commit hashes."""
        output = call_subprocess([self.cmd, 'show-ref'],
                                 show_stdout=False, cwd=location)
        rv = {}
        for line in output.strip().splitlines():
            commit, ref = line.split(' ', 1)
            ref = ref.strip()
            ref_name = None
            if ref.startswith('refs/remotes/'):
                ref_name = ref[len('refs/remotes/'):]
            elif ref.startswith('refs/heads/'):
                ref_name = ref[len('refs/heads/'):]
            elif ref.startswith('refs/tags/'):
                ref_name = ref[len('refs/tags/'):]
            if ref_name is not None:
                rv[ref_name] = commit.strip()
        return rv 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:20,代碼來源:git.py

示例4: get_info

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def get_info(self, location):
        """Returns (url, revision), where both are strings"""
        assert not location.rstrip('/').endswith(self.dirname), 'Bad directory: %s' % location
        output = call_subprocess(
            [self.cmd, 'info', location], show_stdout=False, extra_environ={'LANG': 'C'})
        match = _svn_url_re.search(output)
        if not match:
            logger.warn('Cannot determine URL of svn checkout %s' % display_path(location))
            logger.info('Output that cannot be parsed: \n%s' % output)
            return None, None
        url = match.group(1).strip()
        match = _svn_revision_re.search(output)
        if not match:
            logger.warn('Cannot determine revision of svn checkout %s' % display_path(location))
            logger.info('Output that cannot be parsed: \n%s' % output)
            return url, None
        return url, match.group(1) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:19,代碼來源:subversion.py

示例5: export

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def export(self, location):
        """Export the svn repository at the url to the destination location"""
        url, rev = self.get_url_rev()
        rev_options = get_rev_options(url, rev)
        logger.notify('Exporting svn repository %s to %s' % (url, location))
        logger.indent += 2
        try:
            if os.path.exists(location):
                # Subversion doesn't like to check out over an existing directory
                # --force fixes this, but was only added in svn 1.5
                rmtree(location)
            call_subprocess(
                [self.cmd, 'export'] + rev_options + [url, location],
                filter_stdout=self._filter, show_stdout=False)
        finally:
            logger.indent -= 2 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:18,代碼來源:subversion.py

示例6: export

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def export(self, location):
        """Export the Bazaar repository at the url to the destination location"""
        temp_dir = tempfile.mkdtemp('-export', 'pip-')
        self.unpack(temp_dir)
        if os.path.exists(location):
            # Remove the location to make sure Bazaar can export it correctly
            rmtree(location)
        try:
            call_subprocess([self.cmd, 'export', location], cwd=temp_dir,
                            filter_stdout=self._filter, show_stdout=False)
        finally:
            rmtree(temp_dir) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:14,代碼來源:bazaar.py

示例7: switch

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def switch(self, dest, url, rev_options):
        call_subprocess([self.cmd, 'switch', url], cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:4,代碼來源:bazaar.py

示例8: update

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def update(self, dest, rev_options):
        call_subprocess(
            [self.cmd, 'pull', '-q'] + rev_options, cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:5,代碼來源:bazaar.py

示例9: obtain

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = ['-r', rev]
            rev_display = ' (to revision %s)' % rev
        else:
            rev_options = []
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.notify('Checking out %s%s to %s'
                          % (url, rev_display, display_path(dest)))
            call_subprocess(
                [self.cmd, 'branch', '-q'] + rev_options + [url, dest]) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:15,代碼來源:bazaar.py

示例10: get_url

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def get_url(self, location):
        urls = call_subprocess(
            [self.cmd, 'info'], show_stdout=False, cwd=location)
        for line in urls.splitlines():
            line = line.strip()
            for x in ('checkout of branch: ',
                      'parent branch: '):
                if line.startswith(x):
                    repo = line.split(x)[1]
                    if self._is_local_repository(repo):
                        return path_to_url(repo)
                    return repo
        return None 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:15,代碼來源:bazaar.py

示例11: get_tag_revs

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def get_tag_revs(self, location):
        tags = call_subprocess(
            [self.cmd, 'tags'], show_stdout=False, cwd=location)
        tag_revs = []
        for line in tags.splitlines():
            tags_match = re.search(r'([.\w-]+)\s*(.*)$', line)
            if tags_match:
                tag = tags_match.group(1)
                rev = tags_match.group(2)
                tag_revs.append((rev.strip(), tag.strip()))
        return dict(tag_revs) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:13,代碼來源:bazaar.py

示例12: export

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def export(self, location):
        """Export the Hg repository at the url to the destination location"""
        temp_dir = tempfile.mkdtemp('-export', 'pip-')
        self.unpack(temp_dir)
        try:
            call_subprocess(
                [self.cmd, 'archive', location],
                filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
        finally:
            rmtree(temp_dir) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:12,代碼來源:mercurial.py

示例13: update

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def update(self, dest, rev_options):
        call_subprocess([self.cmd, 'pull', '-q'], cwd=dest)
        call_subprocess(
            [self.cmd, 'update', '-q'] + rev_options, cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:6,代碼來源:mercurial.py

示例14: obtain

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def obtain(self, dest):
        url, rev = self.get_url_rev()
        if rev:
            rev_options = [rev]
            rev_display = ' (to revision %s)' % rev
        else:
            rev_options = []
            rev_display = ''
        if self.check_destination(dest, url, rev_options, rev_display):
            logger.notify('Cloning hg %s%s to %s'
                          % (url, rev_display, display_path(dest)))
            call_subprocess([self.cmd, 'clone', '--noupdate', '-q', url, dest])
            call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:15,代碼來源:mercurial.py

示例15: get_tag_revs

# 需要導入模塊: from pip import util [as 別名]
# 或者: from pip.util import call_subprocess [as 別名]
def get_tag_revs(self, location):
        tags = call_subprocess(
            [self.cmd, 'tags'], show_stdout=False, cwd=location)
        tag_revs = []
        for line in tags.splitlines():
            tags_match = re.search(r'([\w\d\.-]+)\s*([\d]+):.*$', line)
            if tags_match:
                tag = tags_match.group(1)
                rev = tags_match.group(2)
                if "tip" != tag:
                    tag_revs.append((rev.strip(), tag.strip()))
        return dict(tag_revs) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:14,代碼來源:mercurial.py


注:本文中的pip.util.call_subprocess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。