123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import time
- import traceback
- import json
- import __main__ as MAIN
- from lib.cprint import *
- def JSCB(x,sock=None):
- i = ""
- msg = ""
- msgs = []
- try:
-
- for i in x:
-
- msgs = json.loads(i)
- print(" JSCB",msgs)
- if type(msgs) is not list:
- continue
- for msg in msgs:
- print(" ",msg)
-
- if "event" not in msg:
- continue
- if "FIXTURES" == msg["event"]:
- FIX=0
- VAL=""
- ATTR=""
- if "FIX" in msg:
- FIX=msg["FIX"]
- if "VAL" in msg:
- VAL=msg["VAL"]
- if "ATTR" in msg:
- ATTR=msg["ATTR"]
- print(" Xevent",FIX,VAL,ATTR)
-
-
- MAIN.FIXTURES.encoder(str(FIX),ATTR,xval=VAL,xfade=0,xdelay=0)
-
-
-
-
-
-
- if "CLEAR" == msg["event"]:
- MAIN.FIXTURES.clear()
- if "EXEC" == msg["event"]:
- print(" EXEC EXEC")
- val = -1
- exec_nr = -1
- try:
- if "VAL" in msg:
- val = int(msg["VAL"])
- if "EXEC" in msg:
- exec_nr = int(msg["EXEC"])
- if val >= 0 and exec_nr > 0:
- print("PRESET_GOOO",exec_nr,val)
- s = time.time()
- MAIN.master.preset_go(exec_nr-1,xfade=None,val=val)
- e = time.time()
-
-
-
- print("EXE TIME:","{:0.02f}".format(e-s),int(e*100)/100)
- print()
- except Exception as e:
- print("EXEC ERR:",e)
-
- except Exception as e:
- cprint("exception JSCB:",e)
- cprint("- i:",i)
- cprint("- msg:",msgs)
- cprint(traceback.format_exc(),color="red")
- if sock:
- msg = ["Notice: Exception on JSCB-SERVER: ",str(e)]
- msg = json.dumps(msg)
- msg = bytes(msg,"utf8")
- chat._send(sock,msg)
-
|