Or look at the wiki history and try the script before someone "improved" it a view versions ago.
Thanks for the help.
Looking at the older versions gave me clues as to what the formatting/indentations problems were.
I ended up fiddling with those and some other minor things and getting the script to work. I uploaded my changes to the wiki. Hopefully the thing is portable.
(I am not a programmer, so maybe it's just me. But I swear that sometimes folks code things in a willfully hard-to-read manner. Either that or they are working on monitors/terminals that only show two or three lines of code at a time so they have to pack everything as close together as possible.)If anyone cares, here's the script I uploaded:
#!/usr/bin/env python
# this code belongs to public domain
# requires nodes.dat filename passed as argument
import struct
import sys
version = 0
count = 0
# check number of command line arguments
if len(sys.argv) != 2:
sys.exit("Please supply a nodes.dat file!")
nodefile = open(sys.argv[1], 'r')
(count,) = struct.unpack("<I", nodefile.read(4))
if (count == 0):
(version,) = struct.unpack("<I", nodefile.read(4))
(count,) = struct.unpack("<I", nodefile.read(4))
if (version >= 0 & version < 3):
print 'Nodes.dat file version = %d' %(version)
print 'Node count = %d' %(count)
print ' '
if (version == 0):
print ' idx type IP address udp tcp'
else :
print ' idx Ver IP address udp tcp kadUDPKey verified'
for i in xrange(count):
if (version == 0):
(clientid, ip1, ip2, ip3, ip4, udpport, tcpport,
type) = struct.unpack("<16s4BHHB", nodefile.read(25))
ipaddr = '%d.%d.%d.%d' % (ip1, ip2, ip3, ip4)
print '%4d %4d %-15s %5d %5d' % (i, type, ipaddr,
udpport, tcpport)
else :
(clientid, ip1, ip2, ip3, ip4, udpport, tcpport, type, kadUDPkey,
verified) = struct.unpack("<16s4BHHBQB", nodefile.read(34))
ipaddr = '%d.%d.%d.%d' % (ip1, ip2, ip3, ip4)
if (verified == 0): verf='N'
else : verf='Y'
print '%4d %3d %-15s %5d %5d %16x %s' % (i, type, ipaddr, udpport,
tcpport, kadUDPkey, verf)
else :
print 'Cannot handle nodes.dat version %d !' (version)
nodefile.close()