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


Python os.popen4方法代码示例

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


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

示例1: popen4

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def popen4(cmd, mode="t", bufsize=-1):
            """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
            may be a sequence, in which case arguments will be passed directly to
            the program without shell intervention (as with os.spawnv()).  If 'cmd'
            is a string it will be passed to the shell (as with os.system()). If
            'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
            file objects (child_stdin, child_stdout_stderr) are returned."""
            import warnings
            msg = "os.popen4 is deprecated.  Use the subprocess module."
            warnings.warn(msg, DeprecationWarning, stacklevel=2)

            import subprocess
            PIPE = subprocess.PIPE
            p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring),
                                 bufsize=bufsize, stdin=PIPE, stdout=PIPE,
                                 stderr=subprocess.STDOUT, close_fds=True)
            return p.stdin, p.stdout 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:os.py

示例2: shell

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def shell(self, cmd,verbose=0,debug=0,header=''):
    '''
    Replacement method to allow shell commands without them blocking.
    
    @param cmd: Shell command to execute.
    @type cmd: string
    @param verbose: Verbosity
    @type verbose: integer
    @param debug: Debug level
    @type debug: integer
    @param header: Header to be printed before output
    @type header: string
    '''
    stat = 0
    if verbose or debug: print header+cmd
    # flush stdout so we don't mangle python's buffering
    if not debug:
      input, output = os.popen4(cmd)
      print output.read()
      output.close()
      input.close() 
开发者ID:imec-idlab,项目名称:IEEE-802.11ah-ns-3,代码行数:23,代码来源:ipython_view.py

示例3: shell

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def shell(self, cmd,verbose=0,debug=0,header=''):
    """!
    Replacement method to allow shell commands without them blocking.
    
    @param cmd: Shell command to execute.
    @param verbose: Verbosity
    @param debug: Debug level
    @param header: Header to be printed before output
    @return none
    """
    stat = 0
    if verbose or debug: print header+cmd
    # flush stdout so we don't mangle python's buffering
    if not debug:
      input, output = os.popen4(cmd)
      print output.read()
      output.close()
      input.close()

## ConsoleView class 
开发者ID:KTH,项目名称:royal-chaos,代码行数:22,代码来源:ipython_view.py

示例4: popen

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def popen(fullcmd):
        pipein, pipeout = os.popen4(fullcmd)
        return pipeout 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:5,代码来源:_cpmodpy.py

示例5: read_process

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def read_process(cmd, args=''):
    pipein, pipeout = os.popen4('%s %s' % (cmd, args))
    try:
        firstline = pipeout.readline()
        if (re.search(r'(not recognized|No such file|not found)', firstline,
                      re.IGNORECASE)):
            raise IOError('%s must be on your system path.' % cmd)
        output = firstline + pipeout.read()
    finally:
        pipeout.close()
    return output 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:13,代码来源:modfastcgi.py

示例6: popen4

# 需要导入模块: import os [as 别名]
# 或者: from os import popen4 [as 别名]
def popen4(cmd, bufsize=-1, mode='t'):
        """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
        be a sequence, in which case arguments will be passed directly to the
        program without shell intervention (as with os.spawnv()). If 'cmd' is a
        string it will be passed to the shell (as with os.system()). If
        'bufsize' is specified, it sets the buffer size for the I/O pipes. The
        file objects (child_stdout_stderr, child_stdin) are returned."""
        w, r = os.popen4(cmd, mode, bufsize)
        return r, w 
开发者ID:glmcdona,项目名称:meddle,代码行数:11,代码来源:popen2.py


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