当前位置: 首页>>代码示例>>Python>>正文


Python Popen.endswith方法代码示例

本文整理汇总了Python中subprocess.Popen.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.endswith方法的具体用法?Python Popen.endswith怎么用?Python Popen.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen.endswith方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
from subprocess import Popen, PIPE

with open("README.asciidoc", "r") as fin:
    with open("README", "w") as fout:
        fout.write(fin.read())

try:
    # Attempt to try and get the version string using 'git describe'.
    cmd = "git describe --abbrev=8 --dirty"
    ver = Popen(cmd.split(), stdout=PIPE).communicate()[0].strip()
except:
    # Not in a Git repository.
    ver = None
else:
    # Check if the checkout is dirty.
    if ver.endswith("dirty"):
        ver = ver[:-5] + time.strftime("%Y%m%d%H%M")

    # Write the version string to '__version__.py'
    with open("__version__.py", "w") as f:
        f.write("# this file is autogenerated by setup.py\n")
        f.write('version = "{0}"\n'.format(ver))

try:
    # Try to get the version number from __version__.py
    import __version__

    ver = __version__.version
except ImportError:
    # Import failed, version is unknown.
    ver = "unknown"
开发者ID:cjmeyer,项目名称:actions,代码行数:33,代码来源:setup.py

示例2: getEncoding

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
 def getEncoding(self, scriptfile):
     out = Popen(['file', '--', scriptfile], stdout=PIPE).communicate()[0].decode('utf-8', 'replace')
     if out.startswith(scriptfile + ': Python script, ') and out.endswith(' text executable\n'):
         out = out[len(scriptfile + ': Python script, '):]
         out = out.split(' ')[0].lower()
         return out
     return None
开发者ID:maandree,项目名称:xpyp,代码行数:9,代码来源:xpyp.py

示例3: spawn_pipe

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
def spawn_pipe(*command):
    '''
    Spawn an external process and read its output
    
    @param   command:*str  The command arguments
    @return  :str          The output to the command's stdout, with at most one trailing LF removed
    '''
    out = Popen(command, stdin = sys.stdin, stdout = PIPE, stderr = sys.stderr).communicate()[0]
    out = out.decode('utf-8', 'replace')
    return out[:-1] if out.endswith('\n') else out
开发者ID:GNU-Pony,项目名称:pony.computer,代码行数:12,代码来源:pony.computer.py

示例4: sha3override

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
def sha3override(self, filename):
    '''
    Calculate the hash sum of an entire file
    
    @param   filename:str  The filename of which to calculate the hash
    @return  :str          The hash sum in uppercase hexadecimal
    '''
    hashsum = Popen(['spike-ckeccak', filename], stdout = PIPE).communicate()[0]
    hashsum = hashsum.decode('utf-8', 'error')
    if hashsum.endswith('\n'):
        hashsum = hashsum[:-1]
    if '*' in hashsum:
        return sha3override_old(self, filename)
    return hashsum
开发者ID:GNU-Pony,项目名称:spike-ckeccak,代码行数:16,代码来源:spike-ckeccak.py

示例5: expand_signature

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
def expand_signature(sig):
    if not sig:
        return u''
    output = ''
    enc = locale.getpreferredencoding()
    if sig.endswith(u'|'):
        output = Popen(sig[:-1], shell=True, stdout=PIPE).communicate()[0]
    else:
        try:
            f = open(os.path.expanduser(sig), 'r')
            output = f.read()
        except IOError:
            pass
        else:
            f.close()
    output = unicode(output, enc)
    if output.endswith(u'\n'):
        output = output[:-1]
    return output
开发者ID:weisslj,项目名称:muttlearn,代码行数:21,代码来源:muttrc.py

示例6: clipboard_get

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import endswith [as 别名]
 def clipboard_get(self, reg):
     if reg in selections:
         txt = Popen(['xclip', '-selection', selections[reg], '-o'], stdout=PIPE).communicate()[0]
         # emulate vim behavior
         if txt.endswith('\n'):
             txt = txt[:-1]
             regtype = 'V'
         else:
             regtype = 'v'
         return txt.split('\n'), regtype
     else:
         if self.choice is not None:
             c = self.choice
             self.choice = None
             return c
         with HistoryFile(hfile) as hlist:
             if len(hlist) == 0:
                 return ''
             return hlist[0]
开发者ID:bfredl,项目名称:nvim-yanklist,代码行数:21,代码来源:nvim_yanklist.py


注:本文中的subprocess.Popen.endswith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。