0
다중 처리 모듈을 사용하여 병렬로 실행되는 여러 가지 방법이 있지만 올바른 순서로 출력을 표시하지 않습니다. 예를 들어 :파이썬에서 IP 주소로 stdout 정렬
Host:10.76.0.112 Setting up Update Process
Host:10.76.0.114 Running upon kernel reinstallation for GRUB
Host:10.76.0.114 Running: /sbin/new-kernel-pkg --package kernel --mkinitrd
Host:10.76.0.121 Running %pre for the backup-tools
Host:10.76.0.121 Running: yum -y -q update httpd
내가 테스트 스크립트를 사용하여 만든 그것을 시도하지만 그것으로 문제가되었다 :
import StringIO
import string, sys
stdout = sys.stdout
sys.stdout = file = StringIO.StringIO()
print """
10.76.0.114 Initiate Recovery images download
10.76.0.114 Running: wget -b -N -i /tools/recovery/recovery-templates-url.list -o /tools/recovery/recovery-templates-download.log -P /tools/recovery >/dev/null 2>&1
10.76.0.114 2016-06-30 00:33 Finished Xen Hypervisor '4.2' and StorageAPI '4.2' install
10.76.0.114
10.76.0.113 Preparing... ########################################### [100%]
10.76.0.113 package 3-2.noarch is already installed
"""
sys.stdout = stdout
l=file.getvalue()
#print l
l=str(l)
l=l.split()
#print l
print sorted(l, key=lambda k:k[0])
내가 다음 출력을 얻을
Host:10.76.0.114 Running upon kernel reinstallation for GRUB
Host:10.76.0.114 Running: /sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --install --multiboot=/boot/xen.gz 3.18.34-20.el6.x86_64
Host:10.76.0.121 Running %pre for the backup-tools
Host:10.76.0.112 Setting up Update Process
Host:10.76.0.121 Running: yum -y -q update httpd
내가 좋아하는 뭔가를 필요로 할 때 :
['###########################################', "'4.2'", "'4.2'", '-b', '-N', '-i', '-o', '-P', '/tools/recovery/recovery-templates-url.list', '/tools/recovery/recovery-templates-download.log', '/tools/recovery', '00:33', '10.76.0.114', '10.76.0.114', '10.76.0.114', '10.76.0.114', '10.76.0.113', '10.76.0.113', '10.76.0.113', '2>&1', '2016-06-30', '>/dev/null', 'Finished', 'Hypervisor', 'Initiate', 'Preparing...', 'Recovery', 'Running:', 'Retrieving', 'StorageAPI', 'Xen', '[100%]', 'and', 'already', 'download', 'images', 'install', 'is', 'installed', , 'package', 'wget'
H 이 경우 올바른 IP 주소를 얻기 위해 IP 주소별로 정렬 할 수 있습니까?
도와주세요! 여기