Exemple #1
0
def test_write():
    """
    writing to a file-like object; need this for webui.
    """

    class fake_file:
        def __init__(self):
            self.data = []

        def write(self, str):
            self.data.append(str)

    g = graph.Graph()
    g.add_stat("download_rate", color=graph.green)
    g.add_stat("upload_rate", color=graph.blue)
    g.set_left_axis(formatter=deluge.common.fspeed, min=10240)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(900, 150)

    file_like = fake_file()
    surface.write_to_png(file_like)
    data = "".join(file_like.data)

    f = open("file_like.png", "wb")
    f.write(data)
    f.close()
Exemple #2
0
def test_write():
    """
    writing to a file-like object; need this for webui.
    """
    class fake_file:
        def __init__(self):
            self.data = []
        def write(self, str):
            self.data.append(str)

    g = graph.Graph()
    g.add_stat('download_rate', color=graph.green)
    g.add_stat('upload_rate', color=graph.blue)
    g.set_left_axis(formatter=deluge.common.fspeed, min=10240)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(900, 150)

    file_like = fake_file()
    surface.write_to_png(file_like)
    data = "".join(file_like.data)

    f = open("file_like.png","wb")
    f.write(data)
    f.close()
 def update_graph(self):
     width, height = self.graph_widget.allocation.width, self.graph_widget.allocation.height
     context = self.graph_widget.window.cairo_create()
     self.graph.async_request()
     aclient.force_call(True)
     self.graph.draw_to_context(context, width, height)
     return True
Exemple #4
0
def test_async():
    g = graph.Graph()
    g.add_stat('download_rate', color=graph.green)
    g.add_stat('upload_rate', color=graph.blue)
    g.set_left_axis(formatter=deluge.common.fspeed, min=10240)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(600, 300)
    surface.write_to_png('output_async.png')
Exemple #5
0
def test_async():
    g = graph.Graph()
    g.add_stat("download_rate", color=graph.green)
    g.add_stat("upload_rate", color=graph.blue)
    g.set_left_axis(formatter=deluge.common.fspeed, min=10240)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(600, 300)
    surface.write_to_png("output_async.png")
Exemple #6
0
def test_dht():
    """'boring graph, but testing if it works'"""

    g = graph.Graph()
    g.add_stat('dht_nodes', color=graph.orange)
    g.add_stat('dht_cache_nodes', color=graph.blue)
    g.add_stat('dht_torrents', color=graph.green)
    g.add_stat('num_connections', color=graph.darkred) #testing : non dht
    g.set_left_axis(formatter=str, min=10)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(600, 300)
    surface.write_to_png('output_dht.png')
Exemple #7
0
def test_dht():
    """'boring graph, but testing if it works'"""

    g = graph.Graph()
    g.add_stat("dht_nodes", color=graph.orange)
    g.add_stat("dht_cache_nodes", color=graph.blue)
    g.add_stat("dht_torrents", color=graph.green)
    g.add_stat("num_connections", color=graph.darkred)  # testing : non dht
    g.set_left_axis(formatter=str, min=10)
    g.async_request()
    aclient.force_call(True)
    surface = g.draw(600, 300)
    surface.write_to_png("output_dht.png")
 def GET(self, args):
     aclient.force_call(True) #bug, invalid data in async queue?
     self.data = ''
     vars = api.web.input(width = 600, height = 150)
     api.web.header("Content-Type", "image/png")
     g = graph.Graph()
     g.add_stat('download_rate', color=graph.green)
     g.add_stat('upload_rate', color=graph.blue)
     g.set_left_axis(formatter=fspeed, min=10240)
     g.async_request()
     aclient.force_call(True)
     surface = g.draw(int(vars.width), int(vars.height))
     surface.write_to_png(self)
     print self.data
 def GET(self, args):
     "testing, not a final graph"
     aclient.force_call(True) #bug, invalid data in async queue?
     self.data = ''
     vars = api.web.input(width = 600, height = 150)
     api.web.header("Content-Type", "image/png")
     g = graph.Graph()
     g.add_stat('dht_nodes', color=graph.orange)
     g.add_stat('dht_cache_nodes', color=graph.blue)
     g.add_stat('dht_torrents', color=graph.green)
     g.add_stat('num_connections', color=graph.darkred) #testing : non dht
     g.set_left_axis(formatter=str, min=10)
     g.async_request()
     aclient.force_call(True)
     surface = g.draw(int(vars.width), int(vars.height))
     surface.write_to_png(self)
     print self.data