dear all
 
i have the following code that keeps on pinging several sites infinitely
 
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.
 
thank you for any response
 
=======================================================
 
import threading
import os
import Queue
import time
from time import sleep
def showResponse(args):
    """Pretty prints passed tuple to stdout"""
    ip, stdoutLi, threadName = args
    print '%s \t\t\t\t\t\n' % (ip)
    for line in stdoutLi:
        line = line.strip()
        if not line: continue
        print '\t' + line
    print '-'*72
class Pinger(threading.Thread):
    def __init__(self, host, queue):
        threading.Thread.__init__(self)
        self.__host = host
        self.__queue = queue
        self.setDaemon(1)
    def run(self):
        pingCmd = "ping -n 10 -w 1000 " + self.__host
        childStdout = os.popen(pingCmd)
        result = (self.__host, childStdout.readlines(), self.getName())
        childStdout.close()
        self.__queue.put(result)

if __name__ == '__main__':
    hostLi = ['www.google.com','www.yahoo.co.uk']                         # assign 
    
    while 1:                            # infinite loop, 1 is always true
        q = Queue.Queue()
        startA = time.time()
        for host in hostLi:             # for every host in hostLi
            Pinger(host,q).start()
        for i in hostLi:
            showResponse(q.get())       # removes an item out of the list / queue
 
 
=======================================================


On Yahoo!7
Fuel Price Watch - Find and map the cheapest petrol prices in Australia
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to