Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from gradient import poly_gradient
BIND_ADDR = '10.0.0.1'
MCAST_GRP = '224.0.0.251'
MCAST_PORT = 6000
HUE_RANGE = 120
HUE_START = 0
MAX_BRIGHTNESS = 0.2
PIXEL_TABLE = {
"master": 7,
"node1": 6,
"node2": 5,
"node3": 4,
"node4": 3
}
CPU_GRADIENT = list(poly_gradient([(0.0, 0.3, 0.0), (6.0, 0.0, 0.0), (1.0, 1.0, 0.0)], 100))
class Struct(object):
def __init__(self, adict):
self.__dict__.update(adict)
def get_socket(mcast_addr = MCAST_GRP, port = MCAST_PORT, addr = BIND_ADDR):
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
# bind this to the master node's IP address
sock.setsockopt(SOL_IP, IP_ADD_MEMBERSHIP, inet_aton(mcast_addr) + inet_aton(addr))
sock.bind((mcast_addr, port))
mreq = pack("4sl", inet_aton(mcast_addr), INADDR_ANY)
sock.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
return sock