Ping monitor - monitor ip in the background?

ScottZ mylists at
Sun Nov 2 04:26:43 CET 2008

With python 2.6 and wxpython I'm trying to create a system tray icon
application based around an example found here:

The application will simply change the systray icon based on if an ip
address is online or not.

The ping portion looks like this:

if == "nt":  # Windows
    pcmd = "ping -n 1 -w 1000 "
else:                # *nix
    pcmd = "ping -c1 -W1 "

def Ping(ipaddress):
    # execute the code and pipe the result to a string
    p = subprocess.Popen(pcmd + ipaddress, shell=True,
    # give it time to respond

    a ='(.*)ms',
    if a:
        return True
        return False

I've been able to add the ping check as a manual process (via a right
click menu item) but very confused on what direction to take on making
the ping a permanent loop while the app is running. 

I was looking at making the ping routine a thread process but can't
figure out how to feed back the result to the calling app. Global


More information about the Python-list mailing list