|
@@ -177,48 +177,54 @@ def scan():
|
|
|
cprint("_scan Exception as",e,color="red") #,e.argv)
|
|
|
MSG["text"] = e
|
|
|
MSG["bg"] = "red"
|
|
|
+ time.sleep(1)
|
|
|
time.sleep(0.3)
|
|
|
|
|
|
import nodescan2 #as nodescan2
|
|
|
def _scan():
|
|
|
cprint(sys._getframe().f_code.co_name,color="yellow")
|
|
|
- #print(sys._getframe().f_code.co_name)
|
|
|
global rx,node_list,old_tick,Scrollbar
|
|
|
+
|
|
|
ips = nodescan2.os_list_ip() #example
|
|
|
- #for i,v in ips.items():
|
|
|
- # print(" ",i,v)
|
|
|
- # #get_mask(ips)
|
|
|
nodescan2.ArtPoll()
|
|
|
|
|
|
nodes = []
|
|
|
- if mc:
|
|
|
- nodes = []
|
|
|
- artpoll = mc.get("index-artpoll")
|
|
|
- #print()
|
|
|
- #print()
|
|
|
- for k in artpoll:
|
|
|
- #print("_scan",k)
|
|
|
- data = mc.get(k)
|
|
|
- #print(k,data)
|
|
|
- #opcode=convert_to_hex("<h",data[8:10])
|
|
|
- opcode= nodescan2.artnet_get_opcode(data)
|
|
|
- #print(opcode)
|
|
|
- if "ArtPollReplay" in opcode: # != '0x2100': #OpPollReplay
|
|
|
- node = nodescan2.ArtNet_decode_pollreplay(data)
|
|
|
- s = artpoll[k][1]
|
|
|
- s = datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S')
|
|
|
- s = s.timestamp()
|
|
|
- #s = int(time.time()-s.timestamp())
|
|
|
- node["UPDATESTAMP"] = s
|
|
|
- node["BOOT"] = 0
|
|
|
- node["REFRESHSTAMP"] = s
|
|
|
- node["LASTPING"] = 0
|
|
|
- #print("---",node)
|
|
|
- node1 = nodescan.ArtNet_decode_pollreplay(data)
|
|
|
- #print("+++",node1)
|
|
|
- #node=node1
|
|
|
- nodes.append(node)
|
|
|
- #print()
|
|
|
+ if not mc:
|
|
|
+ cprint("mc (memcached) is none",color="red")
|
|
|
+ time.sleep(2)
|
|
|
+ return
|
|
|
+
|
|
|
+ nodes = []
|
|
|
+ artpoll = mc.get("index-artpoll")
|
|
|
+ if not artpoll:
|
|
|
+ time.sleep(2)
|
|
|
+ return
|
|
|
+
|
|
|
+ #print()
|
|
|
+ #print()
|
|
|
+ for k in artpoll:
|
|
|
+ #print("_scan",k)
|
|
|
+ data = mc.get(k)
|
|
|
+ #print(k,data)
|
|
|
+ #opcode=convert_to_hex("<h",data[8:10])
|
|
|
+ opcode= nodescan2.artnet_get_opcode(data)
|
|
|
+ #print(opcode)
|
|
|
+ if "ArtPollReplay" in opcode: # != '0x2100': #OpPollReplay
|
|
|
+ node = nodescan2.ArtNet_decode_pollreplay(data)
|
|
|
+ s = artpoll[k][1]
|
|
|
+ s = datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S')
|
|
|
+ s = s.timestamp()
|
|
|
+ #s = int(time.time()-s.timestamp())
|
|
|
+ node["UPDATESTAMP"] = s
|
|
|
+ node["BOOT"] = 0
|
|
|
+ node["REFRESHSTAMP"] = s
|
|
|
+ node["LASTPING"] = 0
|
|
|
+ #print("---",node)
|
|
|
+ node1 = nodescan.ArtNet_decode_pollreplay(data)
|
|
|
+ #print("+++",node1)
|
|
|
+ #node=node1
|
|
|
+ nodes.append(node)
|
|
|
+ #print()
|
|
|
|
|
|
ok=0
|
|
|
for n in nodes:
|
|
@@ -231,95 +237,8 @@ def _scan():
|
|
|
|
|
|
def refresh_node_list():
|
|
|
cprint(sys._getframe().f_code.co_name,color="yellow")
|
|
|
- refresh_node_list1()
|
|
|
refresh_node_list2()
|
|
|
|
|
|
-def refresh_node_list1():
|
|
|
- cprint(sys._getframe().f_code.co_name,color="yellow")
|
|
|
- #aprint(len(nodes))
|
|
|
- li_node_scroll = li_nodes.yview()
|
|
|
-
|
|
|
- li_nodes.delete("0","end")
|
|
|
- node_nr = 1
|
|
|
- nodesB = {}
|
|
|
- for node in node_list.get(): #nodes:
|
|
|
- k = node["MAC"]
|
|
|
- nodesB[k] = node
|
|
|
-
|
|
|
- #print("k",nodesB.keys())
|
|
|
-
|
|
|
- k_sort = list(nodesB.keys())
|
|
|
- k_sort.sort()
|
|
|
-
|
|
|
- node_list.set([]) # =[]
|
|
|
- for k in k_sort:
|
|
|
- node_list.append(nodesB[k])
|
|
|
-
|
|
|
- #print("k sort",k_sort)
|
|
|
- for k in k_sort:
|
|
|
- node = nodesB[k]
|
|
|
- #print("lll",node)
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" "+ node["lname"])
|
|
|
- bg = "lightgrey"
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
- ip = str(node_nr).rjust(3," ") +" "+ node["IP"]
|
|
|
- bg = ""
|
|
|
- if "PortTypes" in node:
|
|
|
- if not node["PortTypes"]:
|
|
|
- pass
|
|
|
- if node["PortTypes"][0] == "@":
|
|
|
- ip += " DMX-in"
|
|
|
- bg ="yellow"
|
|
|
- else:
|
|
|
- ip += " DMX-out"
|
|
|
- bg ="lightgreen"
|
|
|
- if bg:
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" short Name:"+ node["sname"])
|
|
|
- li_nodes.insert("end",ip)
|
|
|
- if bg:
|
|
|
- color = li_nodes.itemconfig("end", bg=bg)
|
|
|
-
|
|
|
- inout = " UNIVERS OUT="+ str(ord(node["SwOut"][0:1]))+" IN="+ str(ord(node["SwIn"][0:1]))
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") + inout)
|
|
|
-
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +" MAC:"+ node["MAC"])
|
|
|
-
|
|
|
- try:
|
|
|
- last_change=time.time()-float(node["UPDATESTAMP"])
|
|
|
- timeline = ""
|
|
|
- timeline += " CHANGE:%0.1f"% (last_change)
|
|
|
- REFRESHSTAMP = time.time()-float(node["REFRESHSTAMP"])
|
|
|
- timeline +=" PING:%0.1f"% REFRESHSTAMP
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline )
|
|
|
- if last_change > 20:
|
|
|
- color = li_nodes.itemconfig("end", bg="ORANGE")
|
|
|
- except Exception as e:
|
|
|
- li_nodes.insert("end",str(e)+"\n" )
|
|
|
- li_nodes.itemconfig("end", bg="red")
|
|
|
-
|
|
|
- try:
|
|
|
- if node["BOOT"]:
|
|
|
- BOOT = time.time()-float(node["BOOT"])
|
|
|
- else:
|
|
|
- BOOT = 0
|
|
|
- timeline =" BOOT:%0.1f"% BOOT
|
|
|
- li_nodes.insert("end",str(node_nr).rjust(3," ") +timeline +" sec" )
|
|
|
- bg = ""
|
|
|
- except Exception as e:
|
|
|
- li_nodes.insert("end",str(e)+"\n" )
|
|
|
- li_nodes.itemconfig("end", bg="red")
|
|
|
-
|
|
|
-
|
|
|
- if bg:
|
|
|
- li_nodes.itemconfig("end", bg=bg)
|
|
|
- li_nodes.insert("end","*"*60)
|
|
|
- node_nr += 1
|
|
|
- #node_list += [node]
|
|
|
-
|
|
|
- print("scroll:",li_node_scroll)
|
|
|
|
|
|
def refresh_node_list2():
|
|
|
cprint(sys._getframe().f_code.co_name,color="yellow")
|
|
@@ -416,6 +335,7 @@ def refresh_node_list2():
|
|
|
|
|
|
out.append({"txt":"","bg":"white"})
|
|
|
|
|
|
+ # insert nodes in listbox
|
|
|
li_node_scroll = li_nodes.yview()
|
|
|
li_nodes.delete("0","end")
|
|
|
for i in out:
|
|
@@ -466,7 +386,9 @@ def get_form(event=None):
|
|
|
data["mac"] = mac
|
|
|
data["mac_new"] = mac_new
|
|
|
data["univ"] = univ
|
|
|
- print("FORM:",data)
|
|
|
+ print("FORM:")
|
|
|
+ for k,v in data.items():
|
|
|
+ print(" ",k,v)
|
|
|
return data
|
|
|
|
|
|
def send_artaddr(event=None):
|