minor adjustments

This commit is contained in:
Miroslav Stampar 2010-03-12 12:46:26 +00:00
parent fffda32f76
commit 7ec04281dd
3 changed files with 8 additions and 7 deletions

View File

@ -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")

View File

@ -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()

View File

@ -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)