Cleaned up main loop and moved some code to external functions
This commit is contained in:
parent
bd7ad4838d
commit
da362e94fa
47
HTTPy.py
47
HTTPy.py
@ -13,11 +13,37 @@ phrases = ["ping", "whois", "quit", "clear", "help"]
|
|||||||
def printHelp():
|
def printHelp():
|
||||||
print "========================================================"
|
print "========================================================"
|
||||||
print "= help - This screen ="
|
print "= help - This screen ="
|
||||||
print " clear - Clears the screen ="
|
print "= clear - Clears the screen ="
|
||||||
print " ping - Enables/Disables pinging the IP Address ="
|
print "= ping - Enables/Disables pinging the IP Address ="
|
||||||
print "========================================================"
|
print "========================================================"
|
||||||
print "========================================================"
|
print "========================================================"
|
||||||
|
|
||||||
|
def checkPhrase(inputs):
|
||||||
|
for word in phrases:
|
||||||
|
if inputs == word:
|
||||||
|
options(inputs)
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def options(inputs):
|
||||||
|
global whoOn
|
||||||
|
global pingOn
|
||||||
|
|
||||||
|
if inputs == "ping":
|
||||||
|
if pingOn == "P":
|
||||||
|
pingOn = "p"
|
||||||
|
else:
|
||||||
|
pingOn = "P"
|
||||||
|
if inputs == "whois":
|
||||||
|
if whoOn == "W":
|
||||||
|
whoOn = "w"
|
||||||
|
else:
|
||||||
|
whoOn = "W"
|
||||||
|
if inputs == "clear":
|
||||||
|
subprocess.call("clear")
|
||||||
|
if inputs == "help":
|
||||||
|
printHelp()
|
||||||
|
|
||||||
def iterate(inArray, pre):
|
def iterate(inArray, pre):
|
||||||
count = 0
|
count = 0
|
||||||
while count != len(inArray) - 1:
|
while count != len(inArray) - 1:
|
||||||
@ -57,7 +83,6 @@ def getInput():
|
|||||||
global inInput
|
global inInput
|
||||||
global partDomain
|
global partDomain
|
||||||
global running
|
global running
|
||||||
global pingOn
|
|
||||||
inInput = raw_input("["+ pingOn +"][" + whoOn + "] Please enter a domain/IP: ")
|
inInput = raw_input("["+ pingOn +"][" + whoOn + "] Please enter a domain/IP: ")
|
||||||
partDomain = inInput.split(".")
|
partDomain = inInput.split(".")
|
||||||
if inInput == "quit":
|
if inInput == "quit":
|
||||||
@ -66,21 +91,7 @@ def getInput():
|
|||||||
#Main Loop
|
#Main Loop
|
||||||
while running == 1:
|
while running == 1:
|
||||||
getInput()
|
getInput()
|
||||||
if inInput == "ping":
|
if checkPhrase(inInput) == 1 or len(partDomain) == 1:
|
||||||
if pingOn == "P":
|
|
||||||
pingOn = "p"
|
|
||||||
else:
|
|
||||||
pingOn = "P"
|
|
||||||
if inInput == "whois":
|
|
||||||
if whoOn == "W":
|
|
||||||
whoOn = "w"
|
|
||||||
else:
|
|
||||||
whoOn = "W"
|
|
||||||
if inInput == "clear":
|
|
||||||
subprocess.call("clear")
|
|
||||||
if inInput == "help":
|
|
||||||
printHelp()
|
|
||||||
if inInput == "" or inInput == "ping" or inInput == "whois" or inInput == "clear" or inInput == "help":
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if running == 0:
|
if running == 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user