Minor refactoring for all that stickyness

This commit is contained in:
Miroslav Stampar 2012-07-12 15:58:45 +02:00
parent 64143a146f
commit 8e18514e56
3 changed files with 9 additions and 15 deletions

View File

@ -750,7 +750,7 @@ def dataToStdout(data, forceOutput=False, bold=False):
if kb.get("multiThreadMode"):
logging._releaseLock()
setFormatterPrependFlag(len(data) == 1 and data not in ('\n', '\r') or len(data) > 2 and data[0] == '\r' and data[-1] != '\n')
kb.prependFlag = len(data) == 1 and data not in ('\n', '\r') or len(data) > 2 and data[0] == '\r' and data[-1] != '\n'
def dataToTrafficFile(data):
if not conf.trafficFile:
@ -1559,7 +1559,9 @@ def clearConsoleLine(forceOutput=False):
"""
dataToStdout("\r%s\r" % (" " * (getConsoleWidth() - 1)), forceOutput)
setFormatterPrependFlag(False)
kb.prependFlag = False
kb.stickyLevel = None
def parseXmlFile(xmlFile, handler):
"""
@ -3158,14 +3160,6 @@ def extractExpectedValue(value, expected):
return value
def setFormatterPrependFlag(value=True):
"""
Sets logging formatter flag used for signaling if newline is needed before
the logging message itself (used in inference mode)
"""
FORMATTER._prepend_flag = value
def hashDBWrite(key, value, serialize=False):
"""
Helper function for writing session data to HashDB

View File

@ -411,13 +411,12 @@ def __adjustLoggingFormatter():
def format(record):
_ = FORMATTER._format(record)
if FORMATTER._prepend_flag:
if kb.prependFlag:
_ = "\n%s" % _
FORMATTER._prepend_flag = False
kb.prependFlag = False
return _
FORMATTER._format = FORMATTER.format
FORMATTER._prepend_flag = False
FORMATTER.format = format
def __setRequestFromFile():
@ -1497,6 +1496,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
kb.pageStable = None
kb.partRun = None
kb.permissionFlag = False
kb.prependFlag = False
kb.processResponseCounter = 0
kb.proxyAuthHeader = None
kb.queryCounter = 0

View File

@ -26,7 +26,6 @@ from lib.core.common import hashDBWrite
from lib.core.common import incrementCounter
from lib.core.common import randomStr
from lib.core.common import safeStringFormat
from lib.core.common import setFormatterPrependFlag
from lib.core.common import singleTimeWarnMessage
from lib.core.data import conf
from lib.core.data import kb
@ -525,7 +524,8 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
except KeyboardInterrupt:
abortedFlag = True
finally:
setFormatterPrependFlag(False)
kb.prependFlag = False
kb.stickyLevel = None
if finalValue is not None:
finalValue = decodeHexValue(finalValue) if conf.hexConvert else finalValue