Skip to content

Instantly share code, notes, and snippets.

@rozap
Created January 23, 2014 02:33
Show Gist options
  • Save rozap/8571817 to your computer and use it in GitHub Desktop.
Save rozap/8571817 to your computer and use it in GitHub Desktop.
hehehe
import sys
import telnetlib
import re
HOST = "localhost"
tn = telnetlib.Telnet(HOST, 8000)
def _(msg, expected):
tn.write(msg + '\n')
result = tn.read_until(expected, .1)
p = re.compile(expected)
if not p.match(result):
raise Exception("Expected %s but received %s" % (expected, result))
print "%s -> %s : %s" % (msg, expected, result)
def main():
_("1234", "10")
_("12345", "15")
_("12345load12", "1513")
_("12345lod12", "15-13")
_("123f", "6-1")
_("12345uptime232", "15\d{8,12}7")
_("load100000", "11")
_("10101upz10101", "3-13")
_("LOAD", "-1")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment