<div>dear all</div> <div> </div> <div>i have the following code that keeps on pinging several sites infinitely</div> <div> </div> <div>i was wondering if anyone could help me out in how to make the results for each set of loops of the pings to be displayed in an excel file? i need to use the maximum and minimum delay for my project.</div> <div> </div> <div>thank you for any response</div> <div> </div> <div>=======================================================</div> <div> </div> <div>import threading<BR>import os<BR>import Queue<BR>import time<BR>from time import sleep</div> <div>def showResponse(args):<BR> """Pretty prints passed tuple to stdout"""</div> <div> ip, stdoutLi, threadName = args<BR> print '%s \t\t\t\t\t\n' % (ip)</div> <div> for line in stdoutLi:<BR> line =
line.strip()<BR> if not line: continue<BR> print '\t' + line<BR> print '-'*72</div> <div>class Pinger(threading.Thread):</div> <div> def __init__(self, host, queue):<BR> threading.Thread.__init__(self)<BR> self.__host = host<BR> self.__queue = queue<BR> self.setDaemon(1)</div> <div> def run(self):<BR> pingCmd = "ping -n 10 -w 1000 " + self.__host<BR> childStdout = os.popen(pingCmd)<BR> result = (self.__host, childStdout.readlines(), self.getName())<BR>
childStdout.close()<BR> self.__queue.put(result)</div> <div><BR>if __name__ == '__main__':<BR> hostLi = ['www.google.com','www.yahoo.co.uk'] # assign <BR> <BR> while 1: # infinite loop, 1 is always true<BR> q = Queue.Queue()<BR> startA = time.time()<BR> for host in hostLi: # for every host in hostLi<BR>
Pinger(host,q).start()<BR> for i in hostLi:<BR> showResponse(q.get()) # removes an item out of the list / queue</div> <div> </div> <div> </div> <div>=======================================================<BR><BR></div><p>
<hr size=1>On Yahoo!7<br>
<a href="http://au.rd.yahoo.com/mail/tag/fuelprice/**http%3A%2F%2Fau.maps.yahoo.com%2Ffuelwatch%2F">Fuel Price Watch - Find and map the cheapest petrol prices in Australia </a>