#!/usr/bin/python3 import json import memcache try: mc = memcache.Client(['127.0.0.1:11211'], debug=0) except: mc = None def get_programmer(): if mc is None: return DATA=mc.get("fix")#cmd) out=[] for k,v in DATA.items(): ok=0 for kk,vv in v["ATTRIBUT"].items(): if kk.startswith("_"): continue if vv["ACTIVE"]: tmp={"ID":k,"NAME":v["NAME"],"ATTR":kk,"NR":vv["NR"]} #,"FX3":vv["FX2"]} out.append(tmp) ok=1 #if ok: # print() return out def get_patch(): if mc is None: return index=mc.get("PATCH-INDEX") #index")#cmd) index=json.loads(index) out = [] for v in index: patch=mc.get("PATCH-"+str(v)) #index")#cmd) patch=json.loads(patch) u = patch["UNIVERS"] #* 512 d = patch["DMX"] attr = {} for a in patch["ATTRIBUT"]: nr =patch["ATTRIBUT"][a]["NR"] if nr <= 0: continue if a == "END": continue if a.startswith("_"): continue nr = nr + d + u*512 attr[a] = nr-1 tmp = {"FIX":v,"UNI":u,"DMX":d,"NR":nr,"ATTR":attr} out.append(tmp ) return out def patch_order_by_fix(patch): out={} for p in patch: ID = p["FIX"] out[ID] = p #print("patch_order",[ID,p]) return out def get_exec_meta(nr): data = {} try: data = mc.get("EXEC-META-"+str(nr)) data = json.loads(data) except Exception as e: print(" ER1R mc...",e) return data modes = {} def modes_refresh(): global modes try: data = mc.get("MODES") data = json.loads(data) modes = data except Exception as e: print(" ER7R mc...",e) #time.sleep(3) return modes def modes_refresh_loop(): time.sleep(3) while 1: modes_refresh() time.sleep(0.1)