isLocal = re.compile('^(192\.168\.[0-9]{1,3}\.[0-9]{1,3})|'+
'(10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|'+
- '(172\.0?([1][6-9])|([2][0-9])|([3][0-1])\.[0-9]{1,3}\.[0-9]{1,3})|'+
+ '(172\.0?1[6-9]\.[0-9]{1,3}\.[0-9]{1,3})|'+
+ '(172\.0?2[0-9]\.[0-9]{1,3}\.[0-9]{1,3})|'+
+ '(172\.0?3[0-1]\.[0-9]{1,3}\.[0-9]{1,3})|'+
'(127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$')
def findMyIPAddr(addrs, intended_port, local_ok = False):
f.close()
current_ip = ip_search.findall(data)
return current_ip
- except Exception:
+ except:
return []
def uncompact(s):
@param s: the number of bytes
@rtype: C{string}
@return: the formatted size with appropriate units
-
"""
-
- if (s < 1024):
- r = str(s) + 'B'
+ if (s < 1):
+ r = str(int(s*1000.0)/1000.0) + 'B'
+ elif (s < 10):
+ r = str(int(s*100.0)/100.0) + 'B'
+ elif (s < 102):
+ r = str(int(s*10.0)/10.0) + 'B'
+ elif (s < 1024):
+ r = str(int(s)) + 'B'
elif (s < 10485):
r = str(int((s/1024.0)*100.0)/100.0) + 'KiB'
elif (s < 104857):