|
@@ -4,6 +4,8 @@
|
|
|
#from builtins import str, open, range, dict
|
|
|
#from builtins import *
|
|
|
|
|
|
+# pylint: disable=redefined-outer-name,invalid-name,trailing-whitespace,missing-function-docstring
|
|
|
+
|
|
|
"""
|
|
|
This file is part of librelight.
|
|
|
|
|
@@ -139,8 +141,9 @@ def count_active_dmx_ch(dmx):
|
|
|
active = 0
|
|
|
for _,v in enumerate(dmx):
|
|
|
if type(v) is int and v>=1:
|
|
|
- if active < 0:
|
|
|
- active = 0
|
|
|
+ #if active < 0:
|
|
|
+ # active = 0
|
|
|
+ active = max(active,0)
|
|
|
active += 1
|
|
|
return active
|
|
|
# ============================================================
|
|
@@ -157,7 +160,6 @@ class CursesDummy():
|
|
|
self.sel_univ.wrap=1
|
|
|
self.sel_mode=Pager()
|
|
|
self.sel_mode.wrap=1
|
|
|
- pass
|
|
|
def dir(self):
|
|
|
pass
|
|
|
def test(self):
|
|
@@ -170,7 +172,6 @@ class CursesDummy():
|
|
|
pass
|
|
|
def inp(self):
|
|
|
return ""
|
|
|
- pass
|
|
|
def loop(self,**args):
|
|
|
pass
|
|
|
def read(self):
|
|
@@ -294,14 +295,14 @@ class Window():
|
|
|
self.myscreen.addstr(0, 1, str(self._inp) ) #zeile,spalte,text
|
|
|
self.myscreen.refresh()
|
|
|
return self._inp
|
|
|
- except:
|
|
|
+ except Exception as _:
|
|
|
pass#self._inp=""
|
|
|
|
|
|
def clear(self):
|
|
|
self.myscreen.clear()
|
|
|
self.myscreen.border(0)
|
|
|
- curses.nocbreak();
|
|
|
- self.myscreen.keypad(0);
|
|
|
+ curses.nocbreak()
|
|
|
+ self.myscreen.keypad(0)
|
|
|
#self.read()
|
|
|
curses.echo()
|
|
|
curses.resetty()
|
|
@@ -381,7 +382,7 @@ class Window():
|
|
|
try:
|
|
|
x=int(cmd2[1])
|
|
|
self.sel_host.set(x)
|
|
|
- except:
|
|
|
+ except Exception as _:
|
|
|
pass
|
|
|
else:
|
|
|
self.cmd.append(inp2)
|
|
@@ -411,13 +412,13 @@ class Window():
|
|
|
lines = [ ]
|
|
|
#print("cmd:",cmd)
|
|
|
lines.append(" host:"+ hostname +":"+netns+" CMD:" + "".join(self.cmd) )
|
|
|
- if self.mode=="help" or self.mode=="?":
|
|
|
+ if self.mode in ["help","?"]:
|
|
|
lines.append("HILFE[h]: " )
|
|
|
lines.append("MODE [m]: inp, in2 in1 " )
|
|
|
lines.append("UNIV [u]: 0-16 " )
|
|
|
lines.append(" " )
|
|
|
lines.append("HILFE " )
|
|
|
- elif self.mode=="dmx" or self.mode == "DMX":
|
|
|
+ elif self.mode in ["dmx","DMX"]:
|
|
|
self.ttime = time.time()
|
|
|
dmx=self.ohost.get(host,univ=univ2)#univ=head_uni)
|
|
|
info=self.ohost.info()
|
|
@@ -466,7 +467,7 @@ class Window():
|
|
|
lines.append(str(self.ttime))
|
|
|
|
|
|
#screen.draw_lines(lines)
|
|
|
- elif self.mode=="ltp" or self.mode=="LTP":
|
|
|
+ elif self.mode in ["ltp","LTP"]:
|
|
|
self.ttime = time.time()
|
|
|
dmx=self.ohost.get(univ=univ2)#head_uni)
|
|
|
#univ2=""
|
|
@@ -671,8 +672,7 @@ class HostBuffer():
|
|
|
def get(self,host="", univ=""):
|
|
|
if str(univ) in self.__universes:
|
|
|
return self.__universes[str(univ)].get(host)
|
|
|
- else:
|
|
|
- return [-8]*512
|
|
|
+ return [-8]*512
|
|
|
def hosts(self):
|
|
|
hosts = []
|
|
|
for univ in self.__universes:
|
|
@@ -708,6 +708,7 @@ class HostBuffer():
|
|
|
# ============================================================
|
|
|
# Network ====================================================
|
|
|
# ============================================================
|
|
|
+
|
|
|
import socket
|
|
|
import struct
|
|
|
|
|
@@ -724,7 +725,7 @@ def toPrintable(nonprintable):
|
|
|
out = ""
|
|
|
|
|
|
for i in str(nonprintable):
|
|
|
- printable = string.ascii_letters + string.digits +"/()=?{[]}\;:,.-_ "
|
|
|
+ printable = string.ascii_letters + string.digits +r"/()=?{[]}\;:,.-_ "
|
|
|
if str(i) in printable :
|
|
|
out += str(i)
|
|
|
return out
|
|
@@ -846,7 +847,7 @@ class IN_Socket():
|
|
|
self.univ = -1
|
|
|
try:
|
|
|
self.head = struct.unpack("!8sHBBBBHBB" , head )
|
|
|
- except: # Exception as e:
|
|
|
+ except Exception as _:
|
|
|
pass#print( "======E09823" , e)
|
|
|
|
|
|
|
|
@@ -859,15 +860,14 @@ class IN_Socket():
|
|
|
if self.host.startswith("127."): #allways recive localhost on port
|
|
|
self.__poll = 1
|
|
|
return 1
|
|
|
- elif not options.recive:
|
|
|
+ if not options.recive:
|
|
|
self.__poll = 1
|
|
|
return 1
|
|
|
-
|
|
|
- elif self.host.startswith(options.recive):
|
|
|
+ if self.host.startswith(options.recive):
|
|
|
self.__poll = 1
|
|
|
return 1
|
|
|
- else:
|
|
|
- self.__poll = 0
|
|
|
+
|
|
|
+ self.__poll = 0
|
|
|
|
|
|
addr = str(addr)
|
|
|
univ = str(univ)
|
|
@@ -887,7 +887,7 @@ class IN_Socket():
|
|
|
print('recv timed out, retry later')
|
|
|
else:
|
|
|
print(e)
|
|
|
- except: # socket.error as e:
|
|
|
+ except Exception as _: # socket.error as e:
|
|
|
pass
|
|
|
|
|
|
def recive(self):
|
|
@@ -906,10 +906,6 @@ class IN_Socket():
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
|
-import socket
|
|
|
-import struct
|
|
|
-import time
|
|
|
-
|
|
|
|
|
|
class ArtNetNode():
|
|
|
"""simple Object to generate raw ArtNet like Network packages
|
|
@@ -924,7 +920,7 @@ class ArtNetNode():
|
|
|
print("\n"+self.__doc__+"\n")
|
|
|
try:
|
|
|
univ = int(univ)
|
|
|
- except:
|
|
|
+ except Exception as _:
|
|
|
print("errror univ",univ ,"is not int ... set to 7")
|
|
|
univ = 7
|
|
|
self.univ=univ
|
|
@@ -1021,7 +1017,8 @@ class ArtNetNode():
|
|
|
if self.stamp + (1/60) <= time.time():
|
|
|
self.send()
|
|
|
|
|
|
-def artnet_test():
|
|
|
+def artnet_test():
|
|
|
+ # pylint: disable=protected-access
|
|
|
artnet = ArtNetNode()
|
|
|
artnet._tes_frame()
|
|
|
|
|
@@ -1031,7 +1028,7 @@ def artnet_get_opcode(head):
|
|
|
name ="unkown"
|
|
|
try:
|
|
|
opcode=hex(struct.unpack('<h', head[8:10])[0])
|
|
|
- except:
|
|
|
+ except Exception as _:
|
|
|
print("opcode error",[head])
|
|
|
|
|
|
if opcode == '0x5000':
|
|
@@ -1136,6 +1133,7 @@ class Main():
|
|
|
#artnet_out._test_frame()
|
|
|
if options.testuniv:
|
|
|
artnet = ArtNetNode(univ=options.testuniv)
|
|
|
+ # pylint: disable=protected-access
|
|
|
artnet._test_frame()
|
|
|
|
|
|
#ysocket = Socket(bind='127.0.0.1' ,port=6555)
|
|
@@ -1149,6 +1147,7 @@ class Main():
|
|
|
while 1:
|
|
|
poll_flag = 0
|
|
|
if options.testuniv:
|
|
|
+ # pylint: disable=protected-access
|
|
|
artnet._test_frame()
|
|
|
#artnet_out._test_frame()
|
|
|
#if in_socket.poll():
|
|
@@ -1222,6 +1221,7 @@ class Main():
|
|
|
|
|
|
if not poll_flag:
|
|
|
time.sleep(.001)
|
|
|
+
|
|
|
screen.loop()
|
|
|
finally:
|
|
|
pass
|