[svn-commits] mjordan: testsuite/asterisk/trunk r5627 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Sep 20 19:50:24 CDT 2014


Author: mjordan
Date: Sat Sep 20 19:50:19 2014
New Revision: 5627

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5627
Log:
lib/python/asterisk: Fix comparison function for large size differences

In r5615, a comparison function was introduced that attempts to pick the
directory with the most space available, comaparing /tmp and /var/tmp.
Unfortunately, if the blocks available are substantially different, the
value computed by the comparison function is a long, which causes a run-time
exception. Comparison functions must return an integer.

As such, this patch updates the comparison function to always return -1, 0,
or 1. If those aren't integers, then we might as well pack it all up and go
home.

Modified:
    asterisk/trunk/lib/python/asterisk/asterisk.py

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=5627&r1=5626&r2=5627
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Sat Sep 20 19:50:19 2014
@@ -184,8 +184,17 @@
     Note that AST_TEST_ROOT has to be reasonably short (symlinked in /tmp?) so
     we're not running into the asterisk.ctl AF_UNIX limit.
     """
+
     def compare_free_space(x, y):
-        return os.statvfs(y).f_bavail - os.statvfs(x).f_bavail
+        # statvfs can return a long; comparison functions must return an
+        # int. Hence the checks that occur here.
+        blocks_avail = os.statvfs(y).f_bavail - os.statvfs(x).f_bavail
+        if (blocks_avail > 0):
+            return 1
+        elif (blocks_avail < 0):
+            return -1
+        else:
+            return 0
 
     localtest_root = os.getenv("AST_TEST_ROOT")
     if localtest_root:




More information about the svn-commits mailing list