Beispiel #1
0
 def background_thread():
     while True:
         try:
             task = self.sendBuffer.get_nowait()
             if len(task) > 1: socketio.emit(task[0], task[1])
             else: socketio.emit(task[0], None)
             self.sendBuffer.task_done()
         except queue.Empty:
             socketio.sleep(0.1)
Beispiel #2
0
def timerHelper():
    global timer
    while timer > 0:
        timer -= 1
        socketio.emit("timerUpdate", timer)
        socketio.sleep(1)
        if timer == 1:
            winner = calculateWinner()
            socketio.emit("winner", winner)
            timer = 180
            socketio.emit("timerUpdate", timer)
            socketio.emit('updateStories', [])
Beispiel #3
0
        def background_thread():
            while True:
                socketio.emit(
                    'status',
                    self.http2interface.hplayer.players()
                    [0].status())  # {'msg': 'yo', 'timestamp': time.gmtime()}

                if self.sendSettings is not None:
                    socketio.emit('settings', self.sendSettings)
                    self.sendSettings = None

                if self.sendPlaylist is not None:
                    socketio.emit('playlist', self.sendPlaylist)
                    self.sendPlaylist = None

                socketio.sleep(0.1)
Beispiel #4
0
def my_event(data):

    print('Received data: ', data)
    if data == 1:
        command = "120"
        ser.write(command.encode())
    elif data == 0:
        command = "180"
        ser.write(command.encode())
    print("read : {}  len : {}".format(ser.readline(), len(ser.readline())))
    socketio.sleep(0.1)
    while len(ser.readline()) == 0:
        print("wait")
    s = ser.readline()
    s = s.decode('utf-8', 'ignore')
    print(s)
    eventlet.sleep(1)
def graph():
    while True:
            lines = tail(f'{today1}.txt', 2)
            for line in lines:
                data=json.loads(line)

                if data["type"] == "SyntheticValue":
                    label=data["data"]["timestamp"][11:]
                    y=data["data"]["PNL"]
                    list=[label,y]
                    #print(list)
                    socketio.emit('data1',list, broadcast=True)
                    
            
                if data["type"] == "SyntheticRatio":
                    label=data["data"]["timestamp"][11:]
                    y=data["data"]["PNL"]
                    list=[label,y]
                    #print(list)
                    socketio.emit('data2',list, broadcast=True)
                    
            socketio.sleep(20)      
Beispiel #6
0
def graph():
    try:
        while True:
            lines = tail(
                rf"/home/chetan/Desktop/Work/gdfShikha/finalGaph/graph/src/test.txt"
            )
            for line in lines:
                data = json.loads(line)
                print(data)

                if data["type"] == "Reference":

                    list1 = [
                        data["data0"], data["data1"], data["data2"],
                        data["data3"], data["data4"], data["data5"],
                        data["data6"], data["data7"], data["data8"],
                        data["data9"]
                    ]
                    socketio.emit('data1', list1, broadcast=True)

            socketio.sleep(1)
    except ValueError:
        pass
Beispiel #7
0
 def background_thread():
     while True:
         socketio.emit('status', self.player.status()
                       )  # {'msg': 'yo', 'timestamp': time.gmtime()}
         socketio.sleep(0.1)
Beispiel #8
0
def tailing(path, *filename):
    while True:
        print(filename)
        for file in filename:
            line = tail(f'{path}{file}')
            if line:
                datapoints = json.loads(line)
                print('Tailing===', datapoints)

                data = {
                    'chart_name':
                    datapoints['chartname'],
                    'list1': [
                        datapoints["data0"], datapoints["data1"],
                        datapoints["data2"], datapoints["data3"],
                        datapoints["data4"], datapoints["data5"],
                        datapoints["data6"], datapoints["data7"],
                        datapoints["data8"], datapoints["data9"],
                        datapoints["data10"]
                    ]
                }

                if datapoints["type"] == "Reference1":

                    socketio.emit('data1', data, broadcast=True)

                if datapoints["type"] == "Reference2":

                    socketio.emit('data2', data, broadcast=True)

                if datapoints["type"] == "Reference3":

                    socketio.emit('data3', data, broadcast=True)

                if datapoints["type"] == "Reference4":

                    socketio.emit('data4', data, broadcast=True)

                if datapoints["type"] == "Reference5":

                    socketio.emit('data5', data, broadcast=True)

                if datapoints["type"] == "Reference6":

                    socketio.emit('data6', data, broadcast=True)

                if datapoints["type"] == "Reference7":

                    socketio.emit('data7', data, broadcast=True)

                if datapoints["type"] == "Reference8":

                    socketio.emit('data8', data, broadcast=True)

                if datapoints["type"] == "Reference9":

                    socketio.emit('data9', data, broadcast=True)

                if datapoints["type"] == "Reference10":

                    socketio.emit('data10', data, broadcast=True)
        socketio.sleep(2)