Created
July 29, 2010 01:58
-
-
Save rossdylan/496993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Module that wraps around ping and traceroute. The X version uses a new threading thingy | |
""" | |
import procThread | |
import threading | |
__info__ = { | |
"Author": "Ross Delinger", | |
"Version": "1.0", | |
"Dependencies": ["ping", "traceroute"] | |
} | |
def onLoad(): | |
@command("ping", 1) | |
def ping(ctx, cmd, arg, *args): | |
address = args[0] | |
shellCmd = ["ping", "-c", "5", address] | |
pt = procThread(shellCmd, ctx) | |
pt.start() | |
@command(["traceroute", "tr", "tracert"], 1) | |
def tracert(ctx, cmd, arg, *args): | |
address = args[0] | |
shellCmd = [] | |
if os.name == 'nt': | |
shellCmd = ["tracert", address] | |
else: | |
shellCmd = ["traceroute", address] | |
process = MODIFIED_subprocess.Popen(shellCmd, stdin=MODIFIED_subprocess.PIPE, stdout=MODIFIED_subprocess.PIPE, stderr=MODIFIED_subprocess.STDOUT) | |
output = process.communicate() | |
listOut = list(output) | |
for l in listOut: | |
if l != None: | |
ctx.reply(l, "TraceRoute") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment