Beispiel #1
0
 def run(self):
     print("queueuFiller: started in thread %s." % self.ident)
     self._send_to_all_listeners(actions.message("queueuFiller: started in "
                                                 "server thread %s." %
                                                 self.ident))
     self._send_to_all_listeners(actions.create_general_chart("chart1",
                                                     self.chart_options))
     while True:
         self._send_to_all_listeners(actions.add_point("mychart",
                                                 int(time.time()) * 1000,
                                                 random.random()))
         time.sleep(1)
Beispiel #2
0
 def test_create_general_chart(self):
     chart_options = {"title": {"text": "Browser market shares"},
                      "series": [{"type": "pie",
                                  "name": "Browser share",
                                  "data": [["Firefox", 45.0],
                                           ["IE", 26.8],
                                           ["Chrome", 12.8],
                                           ["Safari", 8.5],
                                           ["Opera", 6.2],
                                           ["Others", 0.7]
                                           ]}]}
     self.assertEqual(actions.create_general_chart("chart1",
                                                   chart_options),
                      {"event": "createChart",
                       "data": [json.dumps({"chartID": "chart1",
                                            "chartOptions": chart_options},
                                           sort_keys=True,
                                           separators=(',', ':'))]},
                      "Message should be exactly like second arg.")
Beispiel #3
0
def put_initial_messages(_new_queue):
    memusage_chart_options = {"chart": {"type": "spline",
                                     "animation": "Highcharts.svg"
                                   },
                           "title": {"text": "Max RSS of server"},
                           "xAxis": {"type": "datetime",
                                     "tickPixelInterval": 150
                                    },
                           "yAxis": {"title": {"text": "Max RSS in kB"},
                                     "plotLines": [{
                                                    "value": 0,
                                                    "width": 1,
                                                    "color": "#808080"
                                                    }]
                                     },
                           "series": [{"name": "maxrss",
                                       "data": []}]
                           }

    listeners_chart_options = {"chart": {"type": "spline",
                                         "animation": "Highcharts.svg"
                                         },
                               "title": {"text": "Number of listeners"},
                               "xAxis": {"type": "datetime",
                                         "tickPixelInterval": 150
                                         },
                               "yAxis": {"title": {"text": "Listeners"},
                                         "plotLines": [{
                                                        "value": 0,
                                                        "width": 1,
                                                        "color": "#808080"
                                                        }]
                                         },
                               "series": [{"name": "Listeners",
                                           "data": [{"x": (int(time.time()) - 1)
                                                     * 1000, "y":
                                                     random.random()},
                                                    {"x": int(time.time()) *
                                                     1000, "y":
                                                     random.random()}]}]
                               }

    map_options = {"map": {"options": {"zoom": 4,
                                       "center": [78.840319, 16.585922]
                                       }
                           }
                   }

    example_wordcloud = [{"text": "Amsterdam", "weight": 15},
                         {"text": "Rotterdam", "weight": 15},
                         {"text": "Den Haag", "weight": 8},
                         {"text": "Enschede", "weight": 3},
                         {"text": "Hengelo", "weight": 1.5}]

    for index in range(-19, 0):
        new_point = {"x": (int(time.time()) + index) * 1000,
                     "y": random.random()}
        memusage_chart_options["series"][0]["data"].append(new_point)

#     for index in range(-19, 0):
#         new_point = {"x": (int(time.time()) + index) * 1000,
#                      "y": random.random()}
#         listeners_chart_options["series"][0]["data"].append(new_point)

    _new_queue.put(actions.decode(actions.create_alert_gadget("cell0",
                                      "myAlerter", "Alert!")))
    _new_queue.put(actions.decode(actions.create_alert_gadget("cell9",
                                      "serverinfo", "Server information")))
    _new_queue.put(actions.decode(actions.alert("Server started!",
                                                "serverinfo")))
    _new_queue.put(actions.decode(actions.create_maps_gadget("cell3", "myMap1",
                                                             "Tweet geos",
                                                             map_options)))
    _new_queue.put(actions.decode(actions.add_maps_marker("myMap1", 78.840319,
                                        16.585922, "Jan was here!")))
    _new_queue.put(actions.decode(actions.create_tweetlist_gadget("cell4",
                                        "allTweets", "Random tweets")))
    # _new_queue.put(actions.decode(actions.create_wordcloud_gadget("cell5",
                                        # "myWordCloud", "Dutch cities",
                                        # example_wordcloud)))
    _new_queue.put(actions.decode(actions.create_general_chart("cell1",
                                        "memusage", "Server max RSS",
                                        memusage_chart_options)))
    _new_queue.put(actions.decode(actions.create_general_chart("cell2",
                                        "listeners", "Number of listeners",
                                        listeners_chart_options)))
def put_initial_messages(_new_queue):
    memusage_chart_options = {
        "chart": {
            "type": "spline",
            "animation": "Highcharts.svg"
        },
        "title": {
            "text": "Max RSS of server"
        },
        "xAxis": {
            "type": "datetime",
            "tickPixelInterval": 150
        },
        "yAxis": {
            "title": {
                "text": "Max RSS in kB"
            },
            "plotLines": [{
                "value": 0,
                "width": 1,
                "color": "#808080"
            }]
        },
        "series": [{
            "name": "maxrss",
            "data": []
        }]
    }

    listeners_chart_options = {
        "chart": {
            "type": "spline",
            "animation": "Highcharts.svg"
        },
        "title": {
            "text": "Number of listeners"
        },
        "xAxis": {
            "type": "datetime",
            "tickPixelInterval": 150
        },
        "yAxis": {
            "title": {
                "text": "Listeners"
            },
            "plotLines": [{
                "value": 0,
                "width": 1,
                "color": "#808080"
            }]
        },
        "series": [{
            "name":
            "Listeners",
            "data": [{
                "x": (int(time.time()) - 1) * 1000,
                "y": random.random()
            }, {
                "x": int(time.time()) * 1000,
                "y": random.random()
            }]
        }]
    }

    map_options = {
        "map": {
            "options": {
                "zoom": 4,
                "center": [78.840319, 16.585922]
            }
        }
    }

    example_wordcloud = [{
        "text": "Amsterdam",
        "weight": 15
    }, {
        "text": "Rotterdam",
        "weight": 15
    }, {
        "text": "Den Haag",
        "weight": 8
    }, {
        "text": "Enschede",
        "weight": 3
    }, {
        "text": "Hengelo",
        "weight": 1.5
    }]

    for index in range(-19, 0):
        new_point = {
            "x": (int(time.time()) + index) * 1000,
            "y": random.random()
        }
        memusage_chart_options["series"][0]["data"].append(new_point)

#     for index in range(-19, 0):
#         new_point = {"x": (int(time.time()) + index) * 1000,
#                      "y": random.random()}
#         listeners_chart_options["series"][0]["data"].append(new_point)

    _new_queue.put(
        actions.decode(
            actions.create_alert_gadget("cell0", "myAlerter", "Alert!")))
    _new_queue.put(
        actions.decode(
            actions.create_alert_gadget("cell9", "serverinfo",
                                        "Server information")))
    _new_queue.put(
        actions.decode(actions.alert("Server started!", "serverinfo")))
    _new_queue.put(
        actions.decode(
            actions.create_maps_gadget("cell3", "myMap1", "Tweet geos",
                                       map_options)))
    _new_queue.put(
        actions.decode(
            actions.add_maps_marker("myMap1", 78.840319, 16.585922,
                                    "Jan was here!")))
    _new_queue.put(
        actions.decode(
            actions.create_tweetlist_gadget("cell4", "allTweets",
                                            "Random tweets")))
    # _new_queue.put(actions.decode(actions.create_wordcloud_gadget("cell5",
    # "myWordCloud", "Dutch cities",
    # example_wordcloud)))
    _new_queue.put(
        actions.decode(
            actions.create_general_chart("cell1", "memusage", "Server max RSS",
                                         memusage_chart_options)))
    _new_queue.put(
        actions.decode(
            actions.create_general_chart("cell2", "listeners",
                                         "Number of listeners",
                                         listeners_chart_options)))