Couple of patches for Travis

This commit is contained in:
Miroslav Stampar 2019-05-09 14:10:18 +02:00
parent 7ddb8f7cbe
commit a286734c57
4 changed files with 33 additions and 13 deletions

View File

@ -2265,8 +2265,8 @@ def average(values):
""" """
Computes the arithmetic mean of a list of numbers. Computes the arithmetic mean of a list of numbers.
>>> round(average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 1) >>> "%.1f" % average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
0.9 '0.9'
""" """
return (1.0 * sum(values) / len(values)) if values else None return (1.0 * sum(values) / len(values)) if values else None
@ -2278,8 +2278,8 @@ def stdev(values):
# Reference: http://www.goldb.org/corestats.html # Reference: http://www.goldb.org/corestats.html
>>> round(stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 3) >>> "%.3f" % stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
0.063 '0.063'
""" """
if not values or len(values) < 2: if not values or len(values) < 2:
@ -4701,10 +4701,7 @@ def prioritySortColumns(columns):
def _(column): def _(column):
return column and "id" in column.lower() return column and "id" in column.lower()
if six.PY2: return sorted(sorted(columns, key=len), key=functools.cmp_to_key(lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0))
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
else:
return sorted(sorted(columns, key=len), key=functools.cmp_to_key(lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0))
def getRequestHeader(request, name): def getRequestHeader(request, name):
""" """

View File

@ -6,6 +6,7 @@ See the file 'LICENSE' for copying permission
""" """
import binascii import binascii
import functools
import math import math
import os import os
import random import random
@ -201,6 +202,31 @@ def round(x, d=0):
else: else:
return float(math.ceil((x * p) - 0.5))/p return float(math.ceil((x * p) - 0.5))/p
def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
def __init__(self, obj, *args):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
return mycmp(self.obj, other.obj) > 0
def __eq__(self, other):
return mycmp(self.obj, other.obj) == 0
def __le__(self, other):
return mycmp(self.obj, other.obj) <= 0
def __ge__(self, other):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
def __hash__(self):
raise TypeError('hash not implemented')
return K
# Note: patch for Python 2.6
if not hasattr(functools, "cmp_to_key"):
functools.cmp_to_key = cmp_to_key
if sys.version_info >= (3, 0): if sys.version_info >= (3, 0):
xrange = range xrange = range

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty import six from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.5.68" VERSION = "1.3.5.69"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -68,10 +68,7 @@ def purge(directory):
except: except:
pass pass
if six.PY2: dirpaths.sort(key=functools.cmp_to_key(lambda x, y: y.count(os.path.sep) - x.count(os.path.sep)))
dirpaths.sort(cmp=lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
else:
dirpaths.sort(key=functools.cmp_to_key(lambda x, y: y.count(os.path.sep) - x.count(os.path.sep)))
logger.debug("renaming directory names to random values") logger.debug("renaming directory names to random values")
for dirpath in dirpaths: for dirpath in dirpaths: