less buggy and faster way of converting IP address to signed int, also

means we don't need IPy.
This commit is contained in:
Tim Daly, Jr
2013-04-12 01:54:27 +00:00
parent 7d93f03210
commit 451b48f54c
2 changed files with 2 additions and 6 deletions

View File

@@ -21,10 +21,10 @@ from tomograph import cache
import base64 import base64
import StringIO import StringIO
import IPy
import time import time
import random import random
import socket import socket
import struct
import sys import sys
import traceback import traceback
import atexit import atexit
@@ -67,9 +67,6 @@ def send(span):
def ip_to_i32(ip_str): def ip_to_i32(ip_str):
"""convert an ip address from a string to a signed 32-bit number""" """convert an ip address from a string to a signed 32-bit number"""
a = -0x80000000 + (IPy.IP(ip_str).int() & 0x7fffffff) return struct.unpack('!i', socket.inet_aton(ip_str))[0]
if not -2147483648 <= a <= 2147483647:
print "ARGARG {0}".format(a)
return a

View File

@@ -1,5 +1,4 @@
eventlet eventlet
webob webob
statsd statsd
IPy
thrift thrift