Exemplo n.º 1
0
        timer.sleep(5)  # repeat loop every n seconds

        # contact server and normalize response data
        server_response = check_server(ADDRESS, date)
        server_response = Analysis.normalize(server_response)

        if not server_response.empty:  # if we get a response
            # if we either have no data collected or already have the same set don't repeat analysis
            if data.empty or not server_response.equals(data):
                # add response to local database
                if data.empty:
                    data = server_response
                else:
                    data = pandas.concat([data, server_response], ignore_index=True)

                # normalize data
                data = Analysis.normalize(data)

                analysis = Analysis.analyze(data, 'Temp', lambda x: x > 100)  # send data to be analyzed
                new_alerts = Analysis.convert_to_str(analysis)
                # print easy to read time frames that met the condition if they have not been displayed before
                Analysis.print_analysis(alerts, new_alerts)
                alerts += new_alerts  # adds new alerts to old alerts


        store(data, date)

        data = load_data()

        date = increment_time(date)  # increments time/date for automatic checking