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


Python Popen.startswith方法代码示例

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


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

示例1: test_image_metadata

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test_image_metadata( format, filename, meta_test, meta_test_cnv=None  ):

    print   
    print '---------------------------------------'
    print '%s - %s'%(format, filename)
    print '---------------------------------------'    
  
    out_name = 'tests/_test_metadata_%s.ome.tif'%(filename)
    out_fmt = 'ome-tiff'
    filename = 'images/%s'%(filename)    

    # test if file can be red
    command = [IMGCNV, '-i', filename, '-meta-parsed']
    r = Popen (command, stdout=PIPE).communicate()[0]
    meta_org = parse_imgcnv_info(r)
    
    if r is None or r.startswith('Input format is not supported') or len(meta_org)<=0:
        print_failed('loading metadata', format)
        return        

    #print str(meta_org)

    # test if converted file has same info
    if compare_info(meta_org, meta_test)==True:
        print_passed('reading metadata')

    # convert the file into format   
    command = [IMGCNV, '-i', filename, '-o', out_name, '-t', out_fmt]
    r = Popen (command, stdout=PIPE).communicate()[0] 
        
    # get info from the converted file           
    command = [IMGCNV, '-i', out_name, '-meta-parsed']
    r = Popen (command, stdout=PIPE).communicate()[0]
    meta_cnv = parse_imgcnv_info(r)
    
    if r is None or r.startswith('Input format is not supported') or len(meta_cnv)<=0:
        print_failed('loading written metadata', format)
        return
    else:
        print_passed('loading written metadata')

    #print str(meta_cnv)
   
    if meta_test_cnv is None: meta_test_cnv=meta_test
    if compare_info(meta_cnv, meta_test_cnv)==True:
        print_passed('writing metadata')
            
    print 
开发者ID:wjbeaver,项目名称:Hide-Seep,代码行数:50,代码来源:runtest.py

示例2: encode

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
    def encode(self):
        """
        Note: The output *needs* to have a different name than the original
        The tip for adding the "-g" flag: http://www.infinitecube.com/?p=9
        """

        version, _ = Popen(["ffmpeg", "-version"],
                           stdout=PIPE, stderr=STDOUT).communicate()
        if version.startswith("ffmpeg version 1"):
            scale = "-qscale 0"
        else:
            scale = "-sameq"
        print "Running ffmpeg: encoding and creating keyframes"
        cmd = "ffmpeg -y -i %s -g %s " + scale + " %s"
        if self.h264:
            cmd = ("ffmpeg -y -i %s -vcodec libx264 -coder 0 -flags -loop"
                   " -cmp +chroma -partitions -parti8x8-parti4x4-partp8x8-partb8x8"
                   " -me_method dia -subq 0 -me_range 16 -g %s -keyint_min 25"
                   " -sc_threshold 0 -i_qfactor 0.71 -b_strategy 0 -qcomp 0.6"
                   " -qmin 10 -qmax 51 -qdiff 4 -bf 0 -refs 1 -directpred 1 -trellis 0"
                   " -flags2 -bpyramid-mixed_refs-wpred-dct8x8+fastpskip-mbtree -wpredp"
                   " 0 -aq_mode 0 -crf 30 %s")

        os.system(cmd % (self.filepath,
                         self.framerate * self.seconds_per_keyframe,
                         self.tempfilepath))
开发者ID:antlong,项目名称:castro,代码行数:28,代码来源:__init__.py

示例3: test

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test(options, buildout):
    from subprocess import Popen, PIPE
    import os
    import sys

    python = options['python']
    if not os.path.exists(python):
        raise IOError("There is no file at %s" % python)
    if sys.platform == 'darwin':
        output = Popen([python, "-c", "import platform; print (platform.mac_ver())"], stdout=PIPE).communicate()[0]
        if not output.startswith("('10."):
            raise IOError("Your python at %s doesn't return proper data for platform.mac_ver(), got: %s" % (python, output))
    elif sys.platform == 'linux2' and (2, 4) <= sys.version_info < (2, 5):
        output = Popen([python, "-c", "import socket; print (hasattr(socket, 'ssl'))"], stdout=PIPE).communicate()[0]
        if not output.startswith("True"):
            raise IOError("Your python at %s doesn't have ssl support, got: %s" % (python, output))
开发者ID:biggers,项目名称:buildout.python,代码行数:18,代码来源:test-python.py

示例4: main

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def main():
    print "World of Warcraft LUA Unlocker (x86)"
    osx_version = Popen(["sw_vers", "-productVersion"], stdout=PIPE).communicate()[0]
    if not osx_version.startswith("10.9"):
        print "ERROR: OSX Mavericks is required!"
        sys.exit(1)
    if not os.path.exists(LLDB_BINARY):
        print "ERROR: Missing LLDB - Please Install Xcode Command Line Tools via 'xcode-select --install'"
        sys.exit(1)
    if len(sys.argv) != 2:
        print_usage()
        sys.exit(2)
    try:
        pid = int(sys.argv[1])
    except ValueError:
        print "ERROR: Invalid PID '%s' - must be a number!" % sys.argv[1]
        print_usage()
        sys.exit(2)
    if pid not in get_all_wow_pids():
        print "ERROR: %d is not a valid PID of a World of Warcraft Process!" % pid
        print_usage()
        sys.exit(2)
    
    try:
        print "Unlocking %d..." % pid
        lldb = LLDB(pid)
        print "...LUA unlocked!"
        lldb.wait_for_exit()
    except KeyboardInterrupt:
        print "\nExiting LUA Unlocker..."
        lldb.detach()
开发者ID:kirk24788,项目名称:wowapi,代码行数:33,代码来源:luaUnlock.py

示例5: getEncoding

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [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

示例6: test_image_video

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test_image_video( format, filename, meta_test  ):

    print   
    print '---------------------------------------'
    print '%s - %s'%(format, filename)
    print '---------------------------------------'    
  
    out_name = 'tests/_test_metadata_%s.ome.tif'%(filename)
    out_fmt = 'ome-tiff'
    filename = 'images/%s'%(filename)    

    # test if file can be red
    command = [IMGCNV, '-i', filename, '-meta-parsed']
    r = Popen (command, stdout=PIPE).communicate()[0]
    meta_org = parse_imgcnv_info(r)
    
    if r is None or r.startswith('Input format is not supported') or len(meta_org)<=0:
        print_failed('reading video', format)
        return        

    #print str(meta_org)

    # test if converted file has same info
    if compare_info(meta_org, meta_test)==True:
        print_passed('reading video info')
            
    print 
开发者ID:wjbeaver,项目名称:Hide-Seep,代码行数:29,代码来源:runtest.py

示例7: call

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
 def call(self):
     unread_text = Popen(["newsbeuter", "-x", "print-unread"], stdout=PIPE).communicate()[0]
     if unread_text.startswith("Error:"): return
     unread_items = int(unread_text.split()[0])
     if unread_items > 0:
         yield animate(10, "Newsbeuter: %d unread news." % (unread_items,))
     else:
         yield animate(10, "Newsbeuter: No unread news.")
开发者ID:bigjust,项目名称:dwmstatusline,代码行数:10,代码来源:dwmstat.py

示例8: get_block_device_names

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
 def get_block_device_names(self):
     data = Popen(
         "cat /proc/partitions | awk '{print $4}'", shell=True, stdout=PIPE
     ).stdout.read()
     if data.startswith('name'):
         data = data[4:]
     data = data.strip()
     return data.split('\n')
开发者ID:beastman,项目名称:scalr-test,代码行数:10,代码来源:host_info.py

示例9: _checkInstalled

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
 def _checkInstalled(name, cmdline, expected):
     try:
         out, err = Popen(cmdline, shell=False, stdout=PIPE, stderr=PIPE).communicate()
         out = (out + err).strip()
         if not out.startswith(expected):
             raise RuntimeError()
     except:
         raise RuntimeError(name + " does not appear to be installed")
开发者ID:ChrisCinelli,项目名称:pgessays,代码行数:10,代码来源:pgessay.py

示例10: _update_data

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
 def _update_data(self):
     res = Popen(["watson", "status"], stdout=PIPE).communicate()[0]
     res = res.decode()
     if not res.startswith("No project started"):
         out = self._color_text(res.split()[1].strip(),
                                fg=self.cfg.watson.color_fg,
                                bg=self.cfg.watson.color_bg)
     else:
         out = ""
     return (self.__module__, self._out_format(out))
开发者ID:firecat53,项目名称:py-multistatus,代码行数:12,代码来源:watson.py

示例11: test_video_write

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test_video_write( format, filename ):

    print    
    print '---------------------------------------'
    print '%s - %s'%(format, filename)
    print '---------------------------------------'    
  
    out_name = 'tests/_test_writing_%s.%s'%(filename, format)
    out_fmt = format
    filename = 'images/%s'%(filename) 

    # test if file can be red
    command = [IMGCNV, '-i', filename, '-info']
    r = Popen (command, stdout=PIPE).communicate()[0]
    info_org = parse_imgcnv_info(r)
    
    if r is None or r.startswith('Input format is not supported') or len(info_org)<=0:
        print_failed('loading input info', format)
        return        

    # convert the file into format   
    command = [IMGCNV, '-i', filename, '-o', out_name, '-t', out_fmt]
    r = Popen (command, stdout=PIPE).communicate()[0]    
        
    # get info from the converted file           
    command = [IMGCNV, '-i', out_name, '-info']
    r = Popen (command, stdout=PIPE).communicate()[0]
    info_cnv = parse_imgcnv_info(r)
    
    if r is None or r.startswith('Input format is not supported') or len(info_cnv)<=0:
        print_failed('loading written info', format)
        return
    else:
        print_passed('loading written info')
      
    # test if converted file has same info
    info_test = copy_keys(info_cnv, ('width', 'height'))
    if compare_info(info_org, info_test)==True:
        print_passed('written geometry')
    
    print   
开发者ID:wjbeaver,项目名称:Hide-Seep,代码行数:43,代码来源:runtest.py

示例12: test

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test(options, buildout):
    from subprocess import Popen, PIPE
    import os
    import sys

    python = options['python']
    if not os.path.exists(python):
        raise IOError("There is no file at %s" % python)
    if sys.platform == 'darwin':
        output = Popen([python, "-c", "import platform; print (platform.mac_ver())"], stdout=PIPE).communicate()[0]
        if not output.startswith("('10."):
            raise IOError("Your python at %s doesn't return proper data for platform.mac_ver(), got: %s" % (python, output))
    elif sys.platform == 'linux2' and (2, 4) <= sys.version_info < (2, 5):
        output = Popen([python, "-c", "import socket; print (hasattr(socket, 'ssl'))"], stdout=PIPE).communicate()[0]
        if not output.startswith("True"):
            raise IOError("Your python at %s doesn't have ssl support, got: %s" % (python, output))

    output = Popen([python, "-c", "import readline; print (readline)"], stdout=PIPE).communicate()[0]
    # The leading escape sequence is sometimes printed by readline on import (see https://bugs.python.org/msg191824)
    if not output.lstrip("\x1b[?1034h").startswith("<module"):
        raise IOError("Your python at %s doesn't have readline support, got: %s" % (python,output))
开发者ID:evilbungle,项目名称:buildout.python,代码行数:23,代码来源:test-python.py

示例13: test

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
def test(options, buildout):
    from subprocess import Popen, PIPE
    import os
    import sys

    python = options['python']
    if not os.path.exists(python):
        raise IOError("There is no file at %s" % python)
    if sys.platform == 'darwin':
        output = Popen([python, "-c", "import platform; print (platform.mac_ver())"], stdout=PIPE).communicate()[0]
        if not output.startswith("('10."):
            raise IOError("Your python at %s doesn't return proper data for platform.mac_ver(), got: %s" % (python, output))
开发者ID:bitormetal,项目名称:buildout.python,代码行数:14,代码来源:test-python.py

示例14: js_optimizer

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
  def js_optimizer(filename, passes):
    if not check_engine(NODE_JS):
      raise Exception('Node.js appears to be missing or broken, looked at: ' + str(NODE_JS))

    if type(passes) == str:
      passes = [passes]
    # XXX Disable crankshaft to work around v8 bug 1895
    output, err = Popen([NODE_JS, '--nocrankshaft', JS_OPTIMIZER, filename] + passes, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
    assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + err + '\n\n' + output
    filename += '.jo.js'
    f = open(filename, 'w')
    f.write(output)
    f.close()
    return filename
开发者ID:davidben,项目名称:emscripten,代码行数:16,代码来源:shared.py

示例15: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import startswith [as 别名]
    def __init__(self):

        # Need to find GNU time.  If /usr/bin/time is not GNU time
        # then PUQ expects it to be in the path and called 'gtime'
        tstr = 'gtime'
        try:
            ver = Popen("/usr/bin/time --version", shell=True, stderr=PIPE).stderr.read()
            if ver.startswith("GNU"):
                tstr = '/usr/bin/time'
        except:
            pass

        #self.timestr = tstr + " -f \"HDF5:{'name':'time','value':%e,'desc':''}:5FDH\""
        self.timestr="" #FR
        self.run_num = 0
开发者ID:zoidy,项目名称:puq,代码行数:17,代码来源:hosts.py


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