From bd225516692d41aabdf273ac9cb8de078d1b121a Mon Sep 17 00:00:00 2001 From: Randy Gelhausen Date: Tue, 29 Nov 2016 22:50:09 -0500 Subject: [PATCH] converted hardcoded host/port to arg driven, switched int.from_bytes to Python2 friendly routine --- collector-v9.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/collector-v9.py b/collector-v9.py index 9716553..ad69062 100644 --- a/collector-v9.py +++ b/collector-v9.py @@ -13,9 +13,10 @@ Licensed under MIT License. See LICENSE. import socket import struct +import sys -HOST = '0.0.0.0' -PORT = 9001 +HOST = sys.argv[1] +PORT = int(sys.argv[2]) field_types = { 1: 'IN_BYTES', @@ -151,7 +152,9 @@ class DataFlowSet: dataslice = data[offset:offset+flen] # Better solution than struct.unpack with variable field length - fdata = int.from_bytes(dataslice, byteorder='big') + fdata = 0 + for idx, byte in enumerate(reversed(bytearray(dataslice))): + fdata += byte << (idx * 8) new_record.data[fkey] = fdata