예제 #1
0
파일: test.py 프로젝트: nRuf/deluge
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()
예제 #2
0
파일: test.py 프로젝트: Aniverse/deluge-1
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()
예제 #3
0
 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
예제 #4
0
파일: test.py 프로젝트: Aniverse/deluge-1
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')
예제 #5
0
파일: test.py 프로젝트: nRuf/deluge
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")
예제 #6
0
파일: test.py 프로젝트: Aniverse/deluge-1
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')
예제 #7
0
파일: test.py 프로젝트: nRuf/deluge
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")
예제 #8
0
 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
예제 #9
0
 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