popen
def _command_execute(command_s):"""执行命令,例如command_s=['ls', '-al']"""sp = Popen(command_s, stdout=PIPE, stderr=STDOUT, close_fds=True)output_content = ''for line in iter(sp.stdout.readline, b''):output_content += lineif len(output_content) > 1024 * 4:breaksp.wait()return int(sp.returncode), output_content