Best Python code snippet using autotest_python
process.py
Source:process.py  
...81                    if err.errno == errno.EAGAIN or err.errno == errno.EWOULDBLOCK:82                        data = None83                if data is not None:84                    func(data)85    def read_all_pipes(log, rin, outdata, errdata):86        rlist = rin87        stdoutbuf = b""88        stderrbuf = b""89        try:90            r,w,e = select.select (rlist, [], [], 1)91        except OSError as e:92            if e.errno != errno.EINTR:93                raise94        readextras(r)95        if pipe.stdout in r:96            data = stdoutbuf + pipe.stdout.read()97            if data is not None and len(data) > 0:98                try:99                    data = data.decode("utf-8")100                    outdata.append(data)101                    log.write(data)102                    log.flush()103                    stdoutbuf = b""104                except UnicodeDecodeError:105                    stdoutbuf = data106        if pipe.stderr in r:107            data = stderrbuf + pipe.stderr.read()108            if data is not None and len(data) > 0:109                try:110                    data = data.decode("utf-8")111                    errdata.append(data)112                    log.write(data)113                    log.flush()114                    stderrbuf = b""115                except UnicodeDecodeError:116                    stderrbuf = data117    try:118        # Read all pipes while the process is open119        while pipe.poll() is None:120            read_all_pipes(log, rin, outdata, errdata)121        # Pocess closed, drain all pipes...122        read_all_pipes(log, rin, outdata, errdata)123    finally:124        log.flush()125    if pipe.stdout is not None:126        pipe.stdout.close()127    if pipe.stderr is not None:128        pipe.stderr.close()129    return ''.join(outdata), ''.join(errdata)130def run(cmd, input=None, log=None, extrafiles=None, **options):131    """Convenience function to run a command and return its output, raising an132    exception when the command fails"""133    if not extrafiles:134        extrafiles = []135    if isinstance(cmd, str) and not "shell" in options:136        options["shell"] = True...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
