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


Python Popen.readline方法代码示例

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


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

示例1: iter_processes

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
 def iter_processes():
     pipe = Popen(["ps", "-Af"], stdout=PIPE).stdout
     pipe.readline() # Skip header
     for line in pipe:
         fields = line.split(None, 7)
         pid = int(fields[1])
         command = fields[-1]
         name = basename(command.split()[0])
         yield pid, name
开发者ID:asifurrouf,项目名称:Sauce-RC,代码行数:11,代码来源:uninstall_cleanup.py

示例2: call_fh

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
 def call_fh(self):
     print(self.path)
     out = Popen('fasthenry ' + self.path)
     #out = os.popen('ls')
     while 1:
       if out.readline() == "":
         break
       print(out.readline())
     f = open(join(self.dir, 'Zc.mat'), 'r')
     result = out.read()
     return out, result
开发者ID:Plourde-Research-Lab,项目名称:klayout-macros,代码行数:13,代码来源:Run+in+FastHenry.py

示例3: run_command

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def run_command(command, shell=False):
    if DEBUG:
        print str(command) + "\n"
        return
    sys.__stdout__.write(str(command) + "\n")
    stdout = Popen(command, stdout=PIPE, shell=True).stdout
    line = stdout.readline()
    count = 1 if line else 0
    while line:
        sys.__stdout__.write(line)
        line = stdout.readline()
        count += 1
    return count
开发者ID:KWMalik,项目名称:dotfiles,代码行数:15,代码来源:setup.py

示例4: getNetworkParams

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def getNetworkParams():
    """Return a dictionary of network parameters. Values include:

ssid     Current SSID
bssid    Current Base Station ID
"""
    from subprocess import Popen, PIPE

    networkParams = {}

    airportCmd = "%s -I " % binaries["airport"]

    debug("Running %s" % airportCmd)
    pipe = Popen(airportCmd, shell=True, stdout=PIPE).stdout

    while True:
	line = pipe.readline()
	if len(line) == 0:
	    break
	components = line.split()
	if components[0] == "SSID:":
	    networkParams["ssid"] = components[1]
	    continue
	if components[0] == "BSSID:":
	    networkParams["bssid"] = components[1]
	    continue

    pipe.close()

    # Query interface, which one depends on wether we're using the airport
    # or not
    if networkParams.has_key("SSID"):
	interface = airportIF
    else:
	interface = ethernetIF
    
    ifconfigCmd = "%s %s" % (binaries["ifconfig"], interface)
    debug("Running %s" % ifconfigCmd)
    pipe = Popen(ifconfigCmd, shell=True, stdout=PIPE).stdout

    while True:
	line = pipe.readline()
	if len(line) == 0:
	    break
	components = line.split()
	if components[0] == "inet":
	    networkParams["IPaddress"] = components[1]

    pipe.close()

    return networkParams
开发者ID:von,项目名称:scripts,代码行数:53,代码来源:networkwatcher.py

示例5: runMatch

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
    def runMatch(self,playerOne, playerTwo,gameSeed) :

       
        try :
            inline= Popen("./QtSpimbot -file "+playerOne+" -file2 "+playerTwo
                         + " -randomseed "+gameSeed+ " -randommap -tournament -run -exit_when_done -maponly -quiet ",\
                              stdout=PIPE, shell=True).stdout
            string = "not"
            while(not (string == '')) :
                string = inline.readline()
                if string[:7] == "winner:"  :
                    return string[8:-1]

            print "\nerror, What? This should not be so? Did you quit qtSpim?"
            return self.manual_override(playerOne,playerTwo,gameSeed)

        except KeyboardInterrupt:
            return self.manual_override(playerOne,playerTwo,gameSeed)

        except Alarm:
            print "timeOut"
            killerror= Popen("killall QtSpimbot", stdout=PIPE, shell=True).stdout
            print killerror.read()
            time.sleep(1)
            return "#fail#" 
开发者ID:silverdev,项目名称:Spim_Arena,代码行数:27,代码来源:spimArena.py

示例6: get_surface

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def get_surface( lemma_morph, pos ) :
    """
        Given a lemma+morph in RASP format, returns a tuple containing (surface,
        lemma). Uses morphg to generate the surface, or returns 2 copies of
        the input if morphg was not provided.
    """
    global morphg_file
    parts = lemma_morph.rsplit("+",1)
    if len(parts) == 1 or lemma_morph == "+": # No inflection
        lemma = surface = lemma_morph
    elif len(parts) == 2 and "+" not in parts[0]: # Standard inflected unit
        lemma = parts[0] 
        if morphg_file is not None : 
            lemma_morph = lemma_morph.replace("\"","\\\"")
            cmd = "echo \"%s_%s\" | ${morphg_res:-./%s -t}" % \
                  ( lemma_morph, pos, morphg_file )
            p = Popen(cmd, shell=True, stdout=PIPE).stdout
            #generates the surface form using morphg
            surface = unicode(p.readline(), 'utf-8').split("_")[ 0 ]
            p.close()
        else:
            surface = lemma
    else: # the token contains one or several '+'
        lemma = surface = parts[0]
    return ( surface, lemma )
开发者ID:KWARC,项目名称:mwetoolkit,代码行数:27,代码来源:rasp2xml.py

示例7: getuser

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def getuser(opts):
	user=""
	if opts.user is not None:
		user=opts.user
	else:
		f=Popen(('whoami'),stdout=PIPE).stdout	
		user=f.readline().strip()
	return user
开发者ID:allenzhu,项目名称:multi-operate-snack,代码行数:10,代码来源:snack.py

示例8: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
class PoSlave:
    def __init__(self):
        self.slave = Popen(['coqtop.opt', '-ideslave'],
                           shell=True, stdin=PIPE, stdout=PIPE)

    def write(self, line):
        self.slave.writeline(line)

    def read(self):
        return self.slave.readline()
开发者ID:jaredly,项目名称:coqdocs,代码行数:12,代码来源:pretty.py

示例9: testRESP

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def testRESP(respfile):

 TransFuncsid = "B053F03"
 Respinid= "B053F05"
 

 cmdtrans =  "cat " + respfile + " | grep " + TransFuncsid + " |awk '{print $5 }' "
 cmdResp =  "cat " + respfile + " | grep " +  Respinid + " |awk '{print $6 }' "
 
 t = Popen(cmdtrans, shell=True,close_fds=True, stdout=PIPE).stdout
 r = Popen(cmdResp , shell=True,close_fds=True, stdout=PIPE).stdout
 
 trans = t.readline()[:-1] # We are checking just in the first line with the pattern
 Resp  = r.readline()[:-1]
 
 t.close()
 r.close()
 
 return (trans, Resp)
开发者ID:philcummins,项目名称:ffipy,代码行数:21,代码来源:DataUtils.py

示例10: svn_list

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
 def svn_list(ns, url):
     cmd = "svn ls {}".format(url)
     pipe = Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
     #  you cannot do the "assign and set" trick that you commonly do in other language , typically the C
     #because assignment in python is a "Statement" not a expression.
     #  check  How to assign a variable in IF, and then return it. (Python): http://stackoverflow.com/a/1551223
     # for the iteration recipe,check "reading text files:  http://effbot.org/zone/readline-performance.htm"
     while 1:
         line = pipe.readline()
         if line:
             yield line
开发者ID:joe-bq,项目名称:dynamicProgramming,代码行数:13,代码来源:Syncer.py

示例11: factor_sig

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def factor_sig(n):
    pipe = Popen(["factor", str(n)], shell=False, stdout=PIPE).stdout
    l = pipe.readline()
    pipe.close()
    sig = {}
    factors_s = re.sub("^[^:]*:", "", l)
    for x in re.findall("[0-9]+", factors_s):
        if x not in sig:
            sig[x] = 0
        sig[x] += 1
    return sorted(sig.values())
开发者ID:shlomif,项目名称:project-euler,代码行数:13,代码来源:euler_548_v1.py

示例12: factor_sig

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def factor_sig(n):
    pipe = Popen(['factor', str(n)], shell=False, stdout=PIPE).stdout
    l = pipe.readline()
    pipe.close()
    sig = {}
    factors_s = re.sub('^[^:]*:', '', l)
    for x in re.findall('[0-9]+', factors_s):
        if not x in sig:
            sig[x] = 0
        sig[x] += 1
    return sorted(sig.values())
开发者ID:moritz,项目名称:project-euler,代码行数:13,代码来源:euler_548_v1.py

示例13: executeCmd

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def executeCmd(cmd):
    from subprocess import Popen, PIPE, STDOUT

    fromCmd = Popen(cmd, shell=True, stdout=PIPE,
		    stderr=STDOUT, close_fds=True).stdout

    while True:
	line = fromCmd.readline()
	if len(line) == 0:
	    break
	debug(line)

    fromCmd.close()
开发者ID:von,项目名称:scripts,代码行数:15,代码来源:networkwatcher.py

示例14: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
    def run(self):
        """Xplot file is opened (and normally doesn't print anything to
        stdout). The modified version prints by pressing 'c' the begin and end
        time of the current view. This view is then written to a new file.
        """

        xplot = Popen(["xplot", self.args.xpl_file], bufsize=0, stdout=PIPE,
                shell=False).stdout
        while True:
            line = xplot.readline()
            if not line: break
            print line
            begin, end = re.match("<time_begin:time_end> = "\
                    "<(-?[\d.]+):(-?[\d.]+)>", line).group(1, 2)
            self.cut(float(begin), float(end))
开发者ID:aoimidori27,项目名称:tcp-eval,代码行数:17,代码来源:xplot-cut.py

示例15: command_with_status

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import readline [as 别名]
def command_with_status(cmd):
    wsock = request.environ.get('wsgi.websocket')
    if not wsock:
        abort(400, 'Expected WebSocket request.')
    opts = wsock.receive()
    args = shlex.split("%s %s" % (cmd, opts))

    try:
        pipe = Popen(args, stdout=PIPE).stdout
        while True:
            line = pipe.readline()
            if line:
                wsock.send(line)
            else:
                break
    except WebSocketError:
        pass
开发者ID:bpa,项目名称:SketchWS,代码行数:19,代码来源:sketch_ws.py


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