]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p/util.py
Fix an error in the actions that allowed for the result to be sent twice.
[quix0rs-apt-p2p.git] / apt_p2p / util.py
index 3d1a50eafb4e813eb1e3a360f94dbd52cc546ee9..51582f77ac2ef1d6554e7f60bcd178a251c6c487 100644 (file)
@@ -117,7 +117,7 @@ def ipAddrFromChicken():
          f.close()
          current_ip = ip_search.findall(data)
          return current_ip
-    except Exception:
+    except:
          return []
 
 def uncompact(s):
@@ -160,11 +160,15 @@ def byte_format(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):