Commit 3744ce99 authored by Yoann Pigné's avatar Yoann Pigné

Merge pull request #4 from hhromic/master

Made python sender work with newer gs-core version
parents 5d8c3adf 02e5f69e
# Created by https://www.gitignore.io
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
from gs_netstream.sender import NetStreamProxyGraph, NetStreamSender, Base64NetStreamTransport
import logging
from gs_netstream.sender import NetStreamProxyGraph, NetStreamSender
transport = Base64NetStreamTransport("default","localhost",2001)
sender = NetStreamSender(transport)
logging.basicConfig(level=logging.DEBUG)
sender = NetStreamSender(2012)
proxy = NetStreamProxyGraph(sender)
style = "node{fill-mode:plain;fill-color:gray;size:1px;}"
proxy.addAttribute("stylesheet", style)
proxy.add_attribute("stylesheet", style)
proxy.addAttribute("ui.antialias", True)
proxy.addAttribute("layout.stabilization-limit", 0)
proxy.add_attribute("ui.antialias", True)
proxy.add_attribute("layout.stabilization-limit", 0)
for i in range(0,500):
proxy.addNode(str(i))
if(i>0):
proxy.addEdge(str(i)+"_"+str(i-1), str(i), str(i-1),False)
proxy.addEdge(str(i)+"__"+str(i/2), str(i), str(i/2), False)
\ No newline at end of file
proxy.add_node(str(i))
if i > 0:
proxy.add_edge(str(i) + "_" + str(i-1), str(i), str(i-1), False)
proxy.add_edge(str(i) + "__" + str(i/2), str(i), str(i/2), False)
......@@ -9,54 +9,50 @@ Copyright (c) 2011 University of Luxembourg. All rights reserved.
import sys
import os
import unittest
class AttributeSink(object):
def graphAttributeAdded(self, source_id, time_id, attribute, value):
def graph_attribute_added(self, source_id, time_id, attribute, value):
raise NotImplementedError
def graphAttributeChanged(self, source_id, time_id, attribute, old_value, new_value):
def graph_attribute_changed(self, source_id, time_id, attribute, old_value, new_value):
raise NotImplementedError
def graphAttributeRemoved(self, source_id, time_id, attribute):
def graph_attribute_removed(self, source_id, time_id, attribute):
raise NotImplementedError
def nodeAttributeAdded(self, source_id, time_id, node_id, attribute, value):
def node_attribute_added(self, source_id, time_id, node_id, attribute, value):
raise NotImplementedError
def nodeAttributeChanged(self, source_id, time_id, node_id, attribute, old_value, new_value):
def node_attribute_changed(self, source_id, time_id, node_id, attribute, old_value, new_value):
raise NotImplementedError
def nodeAttributeRemoved(self, source_id, time_id, node_id, attribute):
def node_attribute_removed(self, source_id, time_id, node_id, attribute):
raise NotImplementedError
def edgeAttributeAdded(self, source_id, time_id, edge_id, attribute, value):
def edge_attribute_added(self, source_id, time_id, edge_id, attribute, value):
raise NotImplementedError
def edgeAttributeChanged(self, source_id, time_id, edge_id, attribute, old_value, new_value):
def edge_attribute_changed(self, source_id, time_id, edge_id, attribute, old_value, new_value):
raise NotImplementedError
def edgeAttributeRemoved(self, source_id, time_id, edge_id, attribute):
def edge_attribute_removed(self, source_id, time_id, edge_id, attribute):
raise NotImplementedError
class ElementSink(object):
def nodeAdded(self, source_id, time_id, node_id):
def node_added(self, source_id, time_id, node_id):
raise NotImplementedError
def nodeRemoved(self, source_id, time_id, node_id):
def node_removed(self, source_id, time_id, node_id):
raise NotImplementedError
def edgeAdded(self, source_id, time_id, edge_id, from_node, to_node, directed):
def edge_added(self, source_id, time_id, edge_id, from_node, to_node, directed):
raise NotImplementedError
def edgeRemoved(self, source_id, time_id, edge_id):
def edge_removed(self, source_id, time_id, edge_id):
raise NotImplementedError
def graphCleared(self):
def step_begun(self, source_id, time_id, timestamp):
raise NotImplementedError
def stepBegins(self, source_id, time_id, timestamp):
def graph_cleared(self, source_id, time_id):
raise NotImplementedError
......@@ -13,7 +13,6 @@ EVENT_START = 0x01
"""Not used."""
EVENT_END = 0x02
# ==============================
# = GraphStream's graph events =
# ==============================
......@@ -21,7 +20,6 @@ EVENT_END = 0x02
"""Followed by a node id (TYPE_STRING format)"""
EVENT_ADD_NODE = 0x10
"""Followed by a node id (TYPE_STRING format)"""
EVENT_DEL_NODE = 0x11
......@@ -34,17 +32,14 @@ Followed by
"""
EVENT_ADD_EDGE = 0x12
"""Followed by an edge id (TYPE_STRING format) """
EVENT_DEL_EDGE = 0x13
"""Followed by double (TYPE_DOUBLE format) """
EVENT_STEP = 0x14
EVENT_CLEARED = 0x15
"""
Followed by
- an attribute id (TYPE_STRING format)
......@@ -53,7 +48,6 @@ Followed by
"""
EVENT_ADD_GRAPH_ATTR = 0x16
"""
Followed by
- an attribute id (TYPE_STRING format)
......@@ -69,7 +63,6 @@ Followed by
"""
EVENT_DEL_GRAPH_ATTR = 0x18
"""
Followed by
- an attribute id (TYPE_STRING format)
......@@ -94,8 +87,6 @@ Followed by
"""
EVENT_DEL_NODE_ATTR = 0x1b
"""
Followed by
- an attribute id (TYPE_STRING format)
......@@ -169,7 +160,7 @@ TYPE_LONG = 0x58
"""
An array of longs. Followed by first, a 16-bits integer for the number of
longs and then, a list of 62-bit signed integers
longs and then, a list of 64-bit signed integers
"""
TYPE_LONG_ARRAY = 0x59
......@@ -187,7 +178,6 @@ TYPE_FLOAT_ARRAY = 0x5b
"""Followed by a double precision 64-bits floating point number"""
TYPE_DOUBLE = 0x5c
"""
Array of double. Followed by first, a 16-bits integer for the number of
doubles and then, a list of 64-bit doubles
......@@ -213,4 +203,3 @@ An type-unspecified array. Followed by first, a
themselves. The elements themselves have to give their type.
"""
TYPE_ARRAY = 0x60
This diff is collapsed.
#!/usr/bin/env python
"""Implementation for encoding unsigned varints."""
def encoding_size(value):
"""Computes the encoding size of a value."""
if value < (1L << 7):
return 1
if value < (1L << 14):
return 2
if value < (1L << 21):
return 3
if value < (1L << 28):
return 4
if value < (1L << 35):
return 5
if value < (1L << 42):
return 6
if value < (1L << 49):
return 7
if value < (1L << 56):
return 8
return 9
def encode_unsigned(value):
"""Encodes a Python integer into its varint representation."""
if not isinstance(value, int) or value < 0:
raise TypeError("value argument is not an integer or is negative")
size = encoding_size(value)
buff = bytearray(size)
for i in xrange(size):
head = 128
if i == size - 1:
head = 0
buff[i] = (((value >> (7 * i)) & 127) ^ head) & 255
return buff
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment