Example #1
0
def b*****b(rfid, seconds):
    global stamp, realstamp, punmqtt

    devices = slaves.get_device(rfid)
    slave_id = slaves.get_id(rfid)

    if realstamp[rfid] > 0 and realstamp[rfid] < int(
            datetime.timestamp(datetime.now())):
        showLogo()
        realstamp[rfid] = 0

    for dev in devices:
        if tordevices.support_function(dev['device'], 'b*****b'):
            device = tordevices.get_device(dev['device'])
            funcs = tordevices.get_functions(dev['device'], 'b*****b')
            for i in funcs:
                if int(datetime.timestamp(datetime.now())) > stamp[rfid]:
                    seconds = int(seconds)
                    stamp[rfid] = int(datetime.timestamp(
                        datetime.now())) + seconds + random.randint(10, 120)
                    realstamp[rfid] = int(datetime.timestamp(
                        datetime.now())) + seconds

                    if device['protocol'] == "MQTT":
                        punmqtt.publish(
                            'punisher/slave/' + str(slave_id) + '/b*****b',
                            '{"seconds": 60, "countdown": 100}')
                    if i['image'] != "":
                        showfunc(i['image'])
Example #2
0
def shock_punish( rfid, seconds ):
    global stamp, realstamp
    devices = slaves.get_device( rfid )
    slave_id = slaves.get_id( rfid )

    for dev in devices:
        if tordevices.support_function( dev['device'], 'tens' ):
            device = tordevices.get_device( dev['device'] )
            funcs   = tordevices.get_functions( dev['device'], 'tens' )
            for i in funcs:
                if device['protocol'] == "MQTT":
                    punmqtt.publish('punisher/slave/'+str(slave_id)+'/shock', '{"seconds": '+str(seconds)+', "countdown": '+str(counter)+'}' )
                if i['image'] != "":
                    showfunc( i['image'] )
Example #3
0
def shock( rfid, mode ):
    global stamp, realstamp, punmqtt

    devices = slaves.get_device( rfid )
    slave_id = slaves.get_id( rfid )

    if realstamp[ rfid ] > 0 and realstamp[ rfid ] < int( datetime.timestamp( datetime.now()) ):
        showLogo()
        realstamp[ rfid ] = 0

    for dev in devices:
        if tordevices.support_function( dev['device'], 'tens' ):
            device = tordevices.get_device( dev['device'] )
            funcs   = tordevices.get_functions( dev['device'], 'tens' )
            for i in funcs:
                if int(datetime.timestamp( datetime.now()) ) > stamp[ rfid ]:
                    value = random.randint(0, 30)
                    counter = random.randint(0, 30)
                    if value == 1:
                        mode = randint(1,6)
                        if mode == 1:
                            seconds = 10
                        elif mode == 2:
                            seconds = 30
                        elif mode == 3:
                            seconds = 60
                        elif mode == 4:
                            seconds = 90
                        elif mode == 5:
                            seconds = 120
                        elif mode == 6:
                            seconds = 160

                        stamp[ rfid ]     = int(datetime.timestamp( datetime.now() )) + seconds + counter +random.randint(10, 120)
                        realstamp[ rfid ] = int(datetime.timestamp( datetime.now() )) + seconds + counter
                        if device['protocol'] == "MQTT":
                            punmqtt.publish('punisher/slave/'+str(slave_id)+'/shock', '{"seconds": '+str(seconds)+', "countdown": '+str(counter)+'}' )
                        if i['image'] != "":
                            showfunc( i['image'] )