projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/Makefile: Don't unnecessarily set plugin specific CXXFLAGS.
[collectd.git]
/
contrib
/
collectd_network.py
diff --git
a/contrib/collectd_network.py
b/contrib/collectd_network.py
index
9af0fb0
..
809f19d
100644
(file)
--- a/
contrib/collectd_network.py
+++ b/
contrib/collectd_network.py
@@
-17,10
+17,15
@@
Collectd network protocol implementation.
"""
import socket,struct,sys
"""
import socket,struct,sys
-try:
- from io import StringIO
-except ImportError:
- from cStringIO import StringIO
+import platform
+if platform.python_version() < '2.8.0':
+ # Python 2.7 and below io.StringIO does not like unicode
+ from StringIO import StringIO
+else:
+ try:
+ from io import StringIO
+ except ImportError:
+ from cStringIO import StringIO
from datetime import datetime
from copy import deepcopy
from datetime import datetime
from copy import deepcopy
@@
-76,7
+81,7
@@
def decode_network_values(ptype, plen, buf):
assert double.size == number.size
result = []
assert double.size == number.size
result = []
- for dstype in
buf[header.size+short.size:off
]:
+ for dstype in
[ord(x) for x in buf[header.size+short.size:off]
]:
if dstype == DS_TYPE_COUNTER:
result.append((dstype, number.unpack_from(buf, off)[0]))
off += valskip
if dstype == DS_TYPE_COUNTER:
result.append((dstype, number.unpack_from(buf, off)[0]))
off += valskip