From 7ec04281dd7b2f7a3783e8113a2e460f7c99be19 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 12 Mar 2010 12:46:26 +0000 Subject: [PATCH] minor adjustments --- lib/core/option.py | 1 + lib/core/progress.py | 5 +++-- lib/techniques/blind/inference.py | 9 ++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 3a16e399b..1fe133c1e 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -953,6 +953,7 @@ def __setConfAttributes(): conf.paramNegative = False conf.path = None conf.port = None + conf.progressWidth = 54 conf.retriesCount = 0 conf.scheme = None #conf.seqMatcher = difflib.SequenceMatcher(lambda x: x in " \t") diff --git a/lib/core/progress.py b/lib/core/progress.py index ddb756721..7d5a5751d 100644 --- a/lib/core/progress.py +++ b/lib/core/progress.py @@ -23,19 +23,20 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from lib.core.common import dataToStdout +from lib.core.data import conf class ProgressBar: """ This class defines methods to update and draw a progress bar """ - def __init__(self, minValue=0, maxValue=10, totalWidth=54): + def __init__(self, minValue=0, maxValue=10, totalWidth=None): self.__progBar = "[]" self.__oldProgBar = "" self.__min = int(minValue) self.__max = int(maxValue) self.__span = self.__max - self.__min - self.__width = totalWidth + self.__width = totalWidth if totalWidth else conf.progressWidth self.__amount = 0 self.update() diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index 9337a53eb..ef96ca02d 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -95,7 +95,6 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None showEta = conf.eta and isinstance(length, int) numThreads = min(conf.threads, length) threads = [] - totalWidth = 54 if showEta: progress = ProgressBar(maxValue=length) @@ -106,7 +105,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None infoMsg = "starting %d threads" % numThreads logger.info(infoMsg) - dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * min(length, totalWidth))) + dataToStdout("[%s] [INFO] retrieved: %s" % (time.strftime("%X"), "_" * min(length, conf.progressWidth))) dataToStdout("\r[%s] [INFO] retrieved: " % time.strftime("%X")) else: dataToStdout("[%s] [INFO] retrieved: " % time.strftime("%X")) @@ -191,8 +190,8 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None if value[i] is not None: endCharIndex = max(endCharIndex, i) output = '' - if endCharIndex > totalWidth: - startCharIndex = endCharIndex - totalWidth + if endCharIndex > conf.progressWidth: + startCharIndex = endCharIndex - conf.progressWidth count = 0 for i in xrange(startCharIndex, endCharIndex): output += '_' if value[i] is None else value[i] @@ -200,7 +199,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None count += 1 if value[i] is not None else 0 if startCharIndex > 0: output = '...' + output[3:] - if endCharIndex - startCharIndex == totalWidth: + if endCharIndex - startCharIndex == conf.progressWidth: output = output[:-3] + '...' status = ' %d/%d' % (count, length) output += status if count != length else " "*len(status)