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


Python subprocess.PIPE屬性代碼示例

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


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

示例1: checkdep_ghostscript

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def checkdep_ghostscript():
    if sys.platform == 'win32':
        gs_execs = ['gswin32c', 'gswin64c', 'gs']
    else:
        gs_execs = ['gs']
    for gs_exec in gs_execs:
        try:
            s = subprocess.Popen(
                [gs_exec, '--version'], stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            stdout, stderr = s.communicate()
            if s.returncode == 0:
                v = byte2str(stdout[:-1])
                return gs_exec, v
        except (IndexError, ValueError, OSError):
            pass
    return None, None 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:__init__.py

示例2: get_fontconfig_fonts

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def get_fontconfig_fonts(fontext='ttf'):
    """
    Grab a list of all the fonts that are being tracked by fontconfig
    by making a system call to ``fc-list``.  This is an easy way to
    grab all of the fonts the user wants to be made available to
    applications, without needing knowing where all of them reside.
    """
    fontext = get_fontext_synonyms(fontext)

    fontfiles = {}
    try:
        pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
        output = pipe.communicate()[0]
    except OSError, IOError:
        # Calling fc-list did not work, so we'll just return nothing
        return fontfiles 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:font_manager.py

示例3: dvipng_hack_alpha

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def dvipng_hack_alpha():
    try:
        p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
                  stderr=STDOUT, close_fds=(sys.platform != 'win32'))
    except OSError:
        mpl.verbose.report('No dvipng was found', 'helpful')
        return False
    stdin, stdout = p.stdin, p.stdout
    for line in stdout:
        if line.startswith(b'dvipng '):
            version = line.split()[-1]
            mpl.verbose.report('Found dvipng version %s' % version,
                               'helpful')
            version = version.decode('ascii')
            version = distutils.version.LooseVersion(version)
            return version < distutils.version.LooseVersion('1.6')
    mpl.verbose.report('Unexpected response from dvipng -version', 'helpful')
    return False 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:texmanager.py

示例4: gs_version

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def gs_version(self):
        """
        version of ghostscript.
        """
        try:
            return self._cached["gs_version"]
        except KeyError:
            pass

        from matplotlib.compat.subprocess import Popen, PIPE
        pipe = Popen(self.gs_exe + " --version",
                     shell=True, stdout=PIPE).stdout
        if sys.version_info[0] >= 3:
            ver = pipe.read().decode('ascii')
        else:
            ver = pipe.read()
        gs_version = tuple(map(int, ver.strip().split(".")))

        self._cached["gs_version"] = gs_version
        return gs_version 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:22,代碼來源:backend_ps.py

示例5: checkdep_ghostscript

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def checkdep_ghostscript():
    if sys.platform == 'win32':
        gs_execs = ['gswin32c', 'gswin64c', 'gs']
    else:
        gs_execs = ['gs']
    for gs_exec in gs_execs:
        try:
            s = subprocess.Popen(
                [gs_exec, '--version'], stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            stdout, stderr = s.communicate()
            if s.returncode == 0:
                v = stdout[:-1].decode('ascii')
                return gs_exec, v
        except (IndexError, ValueError, OSError):
            pass
    return None, None 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:19,代碼來源:__init__.py

示例6: fc_match

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def fc_match(pattern, fontext):
        fontexts = get_fontext_synonyms(fontext)
        ext = "." + fontext
        try:
            pipe = subprocess.Popen(
                ['fc-match', '-s', '--format=%{file}\\n', pattern],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            output = pipe.communicate()[0]
        except (OSError, IOError):
            return None

        # The bulk of the output from fc-list is ascii, so we keep the
        # result in bytes and parse it as bytes, until we extract the
        # filename, which is in sys.filesystemencoding().
        if pipe.returncode == 0:
            for fname in output.split(b'\n'):
                try:
                    fname = six.text_type(fname, sys.getfilesystemencoding())
                except UnicodeDecodeError:
                    continue
                if os.path.splitext(fname)[1][1:] in fontexts:
                    return fname
        return None 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:font_manager.py

示例7: dvipng_hack_alpha

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def dvipng_hack_alpha():
    try:
        p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
                  stderr=STDOUT, close_fds=(sys.platform != 'win32'))
        stdout, stderr = p.communicate()
    except OSError:
        mpl.verbose.report('No dvipng was found', 'helpful')
        return False
    lines = stdout.decode('ascii').split('\n')
    for line in lines:
        if line.startswith('dvipng '):
            version = line.split()[-1]
            mpl.verbose.report('Found dvipng version %s' % version,
                               'helpful')
            version = distutils.version.LooseVersion(version)
            return version < distutils.version.LooseVersion('1.6')
    mpl.verbose.report('Unexpected response from dvipng -version', 'helpful')
    return False 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:20,代碼來源:texmanager.py

示例8: gs_version

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def gs_version(self):
        """
        version of ghostscript.
        """
        try:
            return self._cached["gs_version"]
        except KeyError:
            pass

        from matplotlib.compat.subprocess import Popen, PIPE
        s = Popen(self.gs_exe + " --version",
                     shell=True, stdout=PIPE)
        pipe, stderr = s.communicate()
        if six.PY3:
            ver = pipe.decode('ascii')
        else:
            ver = pipe
        try:
            gs_version = tuple(map(int, ver.strip().split(".")))
        except ValueError:
            # if something went wrong parsing return null version number
            gs_version = (0, 0)
        self._cached["gs_version"] = gs_version
        return gs_version 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:backend_ps.py

示例9: check_for

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def check_for(texsystem):
    header = """
    \\documentclass{minimal}
    \\usepackage{pgf}
    \\begin{document}
    \\typeout{pgfversion=\\pgfversion}
    \\makeatletter
    \\@@end
    """
    try:
        latex = subprocess.Popen(["xelatex", "-halt-on-error"],
                                 stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE)
        stdout, stderr = latex.communicate(header.encode("utf8"))
    except OSError:
        return False

    return latex.returncode == 0 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:20,代碼來源:test_backend_pgf.py

示例10: verify

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def verify(filename):
    """Verify the file through some sort of verification tool."""
    if not os.path.exists(filename):
        raise IOError("'%s' does not exist" % filename)
    base, extension = filename.rsplit('.', 1)
    verifier = verifiers.get(extension, None)
    if verifier is not None:
        cmd = verifier(filename)
        pipe = subprocess.Popen(
            cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = pipe.communicate()
        errcode = pipe.wait()
        if errcode != 0:
            msg = "File verification command failed:\n%s\n" % ' '.join(cmd)
            if stdout:
                msg += "Standard output:\n%s\n" % stdout
            if stderr:
                msg += "Standard error:\n%s\n" % stderr
            raise IOError(msg) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:21,代碼來源:compare.py

示例11: checkdep_ghostscript

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def checkdep_ghostscript():
    if checkdep_ghostscript.executable is None:
        if sys.platform == 'win32':
            # mgs is the name in miktex
            gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
        else:
            gs_execs = ['gs']
        for gs_exec in gs_execs:
            try:
                s = subprocess.Popen(
                    [str(gs_exec), '--version'], stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE)
                stdout, stderr = s.communicate()
                if s.returncode == 0:
                    v = stdout[:-1].decode('ascii')
                    checkdep_ghostscript.executable = gs_exec
                    checkdep_ghostscript.version = v
            except (IndexError, ValueError, OSError):
                pass
    return checkdep_ghostscript.executable, checkdep_ghostscript.version 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:22,代碼來源:__init__.py

示例12: checkdep_inkscape

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def checkdep_inkscape():
    if checkdep_inkscape.version is None:
        try:
            s = subprocess.Popen([str('inkscape'), '-V'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            stdout, stderr = s.communicate()
            lines = stdout.decode('ascii').split('\n')
            for line in lines:
                if 'Inkscape' in line:
                    v = line.split()[1]
                    break
            checkdep_inkscape.version = v
        except (IndexError, ValueError, UnboundLocalError, OSError):
            pass
    return checkdep_inkscape.version 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:18,代碼來源:__init__.py

示例13: dvipng_hack_alpha

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def dvipng_hack_alpha():
    try:
        p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE,
                  stderr=STDOUT, close_fds=(sys.platform != 'win32'))
        stdout, stderr = p.communicate()
    except OSError:
        _log.info('No dvipng was found')
        return False
    lines = stdout.decode(sys.getdefaultencoding()).split('\n')
    for line in lines:
        if line.startswith('dvipng '):
            version = line.split()[-1]
            _log.info('Found dvipng version %s', version)
            version = distutils.version.LooseVersion(version)
            return version < distutils.version.LooseVersion('1.6')
    _log.info('Unexpected response from dvipng -version')
    return False 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:19,代碼來源:texmanager.py

示例14: gs_version

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def gs_version(self):
        """
        version of ghostscript.
        """
        try:
            return self._cached["gs_version"]
        except KeyError:
            pass

        from matplotlib.compat.subprocess import Popen, PIPE
        s = Popen([self.gs_exe, "--version"], stdout=PIPE)
        pipe, stderr = s.communicate()
        if six.PY3:
            ver = pipe.decode('ascii')
        else:
            ver = pipe
        try:
            gs_version = tuple(map(int, ver.strip().split(".")))
        except ValueError:
            # if something went wrong parsing return null version number
            gs_version = (0, 0)
        self._cached["gs_version"] = gs_version
        return gs_version 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:25,代碼來源:backend_ps.py

示例15: isAvailable

# 需要導入模塊: from matplotlib.compat import subprocess [as 別名]
# 或者: from matplotlib.compat.subprocess import PIPE [as 別名]
def isAvailable(cls):
        '''
        Check to see if a MovieWriter subclass is actually available by
        running the commandline tool.
        '''
        bin_path = cls.bin_path()
        if not bin_path:
            return False
        try:
            p = subprocess.Popen(
                bin_path,
                shell=False,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                creationflags=subprocess_creation_flags)
            return cls._handle_subprocess(p)
        except OSError:
            return False 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:20,代碼來源:animation.py


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