#NEWLINE# def run_proc( proc , retcode , timeout = None ) : #NEWLINE# #INDENT# 'Waits for the given process to terminate, with the expected exit code\n\n    :param proc: a running Popen-like object\n\n    :param retcode: the expected return (exit) code of the process. It defaults to 0 (the\n                    convention for success). If ``None``, the return code is ignored.\n                    It may also be a tuple (or any object that supports ``__contains__``)\n                    of expected return codes.\n\n    :param timeout: the number of seconds (a ``float``) to allow the process to run, before\n                    forcefully terminating it. If ``None``, not timeout is imposed; otherwise\n                    the process is expected to terminate within that timeout value, or it will\n                    be killed and :class:`ProcessTimedOut <plumbum.cli.ProcessTimedOut>`\n                    will be raised\n\n    :returns: A tuple of (return code, stdout, stderr)\n    ' #NEWLINE# _register_proc_timeout ( timeout , timeout ) #NEWLINE# ( stdout , stderr ) = proc . communicate ( ) #NEWLINE# proc . _end_time = time . time ( ) #NEWLINE# if ( not stdout ) : #NEWLINE# #INDENT# stdout = six . b ( '' ) #NEWLINE# #UNINDENT# if ( not stderr ) : #NEWLINE# #INDENT# stderr = six . b ( '' ) #NEWLINE# #UNINDENT# if getattr ( proc , 'encoding' , None ) : #NEWLINE# #INDENT# stdout = stdout . decode ( proc . encoding , 'ignore' ) #NEWLINE# stderr = stderr . decode ( proc . encoding , 'ignore' ) #NEWLINE# #UNINDENT# return _check_process ( proc , retcode , timeout , stdout , stderr )