|
@@ -20,16 +20,17 @@ import nodescan
|
|
|
title = "TK-Ping"
|
|
|
sys.stdout.write("\x1b]2;"+title+"\x07")
|
|
|
|
|
|
-font1 = ("Helvetica", 8)
|
|
|
-font2 = ("Helvetica", 12) # 10
|
|
|
-font3 = ("Helvetica", 12) # 16
|
|
|
-font20 = font=("Helvetica", 12) # 22
|
|
|
-font120 = font=("Helvetica", 22) # 22
|
|
|
+font1 = ("freemonobold", 8)
|
|
|
+font2 = ("freemonobold", 8)#12) # 10
|
|
|
+font3 = ("freemonobold", 8) #12) # 16
|
|
|
+font20 = font=("freemonobold", 12) # 22
|
|
|
+font120 = font=("freemonobold", 22) # 22
|
|
|
|
|
|
|
|
|
root = Tkinter.Tk()
|
|
|
#root.geometry("900x700+100+100")
|
|
|
-root.geometry("500x800+100+100")
|
|
|
+#root.geometry("500x800+100+100")
|
|
|
+root.geometry("400x600+100+100")
|
|
|
root.title( title)
|
|
|
|
|
|
eframe = Tkinter.Frame(root)
|
|
@@ -60,13 +61,19 @@ for ip in txt:
|
|
|
print("-",ip)
|
|
|
local_ips.append(ip)
|
|
|
|
|
|
+#-------------------------------------------- line
|
|
|
+lb = Tkinter.Label(line_frame,text="ping -c1 ",width=8,font=font2) #,state="disabled")
|
|
|
+lb.pack(side="left",expand=0,fill="y")
|
|
|
+#lb.insert("end","ping -c1 ")
|
|
|
+#-------------------------------------------- line
|
|
|
+
|
|
|
#local_ips.sort()
|
|
|
|
|
|
option_list=local_ips
|
|
|
p_variable = Tkinter.StringVar(root)
|
|
|
p_variable.set(option_list[0]) # default value
|
|
|
e_poll_new = Tkinter.OptionMenu(line_frame, p_variable,*option_list)
|
|
|
-e_poll_new.configure(font=("Helvetica", 13))
|
|
|
+e_poll_new.configure(font=font2)
|
|
|
e_poll_new.configure(width=16)
|
|
|
e_poll_new["bg"] = "#fff"
|
|
|
#print(dir(e_poll_new))
|
|
@@ -89,32 +96,52 @@ def sort_list():
|
|
|
lines.sort()
|
|
|
b_scan.delete("0.0","end")
|
|
|
for line in lines:
|
|
|
- #print("-",[line])
|
|
|
+ print("-",[line])
|
|
|
if line:
|
|
|
b_scan.insert("end",line+"\n")
|
|
|
|
|
|
-def cmd(CMD):
|
|
|
- #print("CMD:",CMD)
|
|
|
- #b_scan.insert("end",CMD+"\n")
|
|
|
+def clean_ip(ip):
|
|
|
+ if "/" in ip:
|
|
|
+ ip = ip.split("/")[0]
|
|
|
+ ip = ip.replace("_","")
|
|
|
+ ip = ip.split(".")
|
|
|
+ ip = "{}.{}.{}.{}".format(int(ip[0]),int(ip[1]),int(ip[2]),int(ip[3]))
|
|
|
+
|
|
|
+ return ip
|
|
|
+
|
|
|
+def prettier_ip(ip):
|
|
|
+ if "/" in ip:
|
|
|
+ ip = ip.split("/")[0]
|
|
|
+ ip = ip.replace("_","")
|
|
|
+ ip = ip.split(".")
|
|
|
+ ip = "{:03}.{:03}.{:03}.{:03}".format(int(ip[0]),int(ip[1]),int(ip[2]),int(ip[3]))
|
|
|
+ return ip
|
|
|
+
|
|
|
+def cmd(IP):
|
|
|
+ #print("IP:",IP)
|
|
|
+ #b_scan.insert("end",IP+"\n")
|
|
|
|
|
|
ip = "xxx"
|
|
|
try:
|
|
|
- ip = p_variable.get() # = Tkinter.StringVar(root)
|
|
|
- ip = ip.split("/")[0]
|
|
|
- ip = ip.split(".")
|
|
|
- ip = "{}.{}.{}.{:03}".format(ip[0],ip[1],ip[2],int(ip[3]))
|
|
|
+ myip = p_variable.get() # = Tkinter.StringVar(root)
|
|
|
+ myip = clean_ip(myip)
|
|
|
except Exception as e:
|
|
|
print("err",e)
|
|
|
|
|
|
- r=os.popen(CMD+" 2> /dev/null ")
|
|
|
+ CMD = "ping -c1 '{}' 2> /dev/null".format(clean_ip(IP))
|
|
|
+ print(CMD)
|
|
|
+ r=os.popen(CMD)
|
|
|
+ #CMD = "ping -c1 '{}' 2> /dev/null".format(IP)
|
|
|
+
|
|
|
for line in r.readlines():
|
|
|
#print([line])
|
|
|
+ #print(IP,[line],CMD)
|
|
|
if " packets transmitted" in line and not "100%" in line:
|
|
|
- print(CMD,[line])
|
|
|
- if ip in CMD:
|
|
|
- b_scan.insert("end",str(CMD).ljust(50," ")+str(" OK <-- me ")+"\n")
|
|
|
+ print(IP,[line],CMD)
|
|
|
+ if myip in clean_ip(IP):
|
|
|
+ b_scan.insert("end",str(IP).ljust(50," ")+str(" OK <-- me ")+"\n")
|
|
|
else:
|
|
|
- b_scan.insert("end",str(CMD).ljust(50," ")+str(" OK")+"\n")
|
|
|
+ b_scan.insert("end",str(IP).ljust(50," ")+str(" OK")+"\n")
|
|
|
|
|
|
|
|
|
ping_lock=0
|
|
@@ -128,27 +155,35 @@ def _ping():
|
|
|
ip = p_variable.get() # = Tkinter.StringVar(root)
|
|
|
ip = ".".join(ip.split(".")[:-1])
|
|
|
print("ip",ip)
|
|
|
+
|
|
|
+ out=[]
|
|
|
for i in range(1,255):
|
|
|
- CMD="ping -c1 '{}.{:03}' ".format(ip,i)
|
|
|
- #cmd(CMD)
|
|
|
- thread.start_new_thread(cmd,(CMD,)) #node_cmd_recive, () )
|
|
|
+ IP="{}.{}".format(ip,i)
|
|
|
+ IP= prettier_ip(IP)
|
|
|
+ out.append(IP)
|
|
|
+
|
|
|
+ for o in out:
|
|
|
+ print(":",o)
|
|
|
+
|
|
|
+ for IP in out:
|
|
|
+ thread.start_new_thread(cmd,(IP,))
|
|
|
+
|
|
|
ping_lock=0
|
|
|
btn_ping["bg"] = "green"
|
|
|
- #sort_list()
|
|
|
|
|
|
def ping():
|
|
|
thread.start_new_thread(_ping,()) #node_cmd_recive, () )
|
|
|
|
|
|
#-------------------------------------------- line
|
|
|
|
|
|
-btn_ping = Tkinter.Button(line_frame,text="start Ping",width=8,command=ping,font=font2)
|
|
|
+btn_ping = Tkinter.Button(line_frame,text="start Ping",width=7,command=ping,font=font2)
|
|
|
btn_ping.pack(side="left",expand=0,fill="y")
|
|
|
|
|
|
#-------------------------------------------- line
|
|
|
-b_scan2 = Tkinter.Button(line_frame,text="sort",width=8,command=sort_list,font=font2)
|
|
|
+b_scan2 = Tkinter.Button(line_frame,text="sort",width=5,command=sort_list,font=font2)
|
|
|
b_scan2.pack(side="left",expand=0,fill="y")
|
|
|
#-------------------------------------------- line
|
|
|
-b_scan2 = Tkinter.Button(line_frame,text="clear",width=8,command=clear_list,font=font2)
|
|
|
+b_scan2 = Tkinter.Button(line_frame,text="clear",width=5,command=clear_list,font=font2)
|
|
|
b_scan2.pack(side="left",expand=0,fill="y")
|
|
|
#-------------------------------------------- line
|
|
|
|
|
@@ -158,7 +193,7 @@ eframe10.pack(side="top",expand=1,fill="both")
|
|
|
scroll_bar = Tkinter.Scrollbar(eframe10)
|
|
|
scroll_bar.pack(side="right", fill="y")
|
|
|
|
|
|
-b_scan = Tkinter.Text(eframe10,width=20,font=font2,yscrollcommand = scroll_bar.set)
|
|
|
+b_scan = Tkinter.Text(eframe10,width=16,font=font1,yscrollcommand = scroll_bar.set)
|
|
|
b_scan.pack(side="left",expand=1,fill="both")
|
|
|
|
|
|
scroll_bar.config( command = b_scan.yview )
|