minor update

This commit is contained in:
Miroslav Stampar 2011-10-11 22:40:00 +00:00
parent 7956390631
commit e3a719e7d2
3 changed files with 11 additions and 5 deletions

View File

@ -41,6 +41,7 @@ class _ThreadData(threading.local):
self.lastQueryDuration = 0 self.lastQueryDuration = 0
self.lastRequestMsg = None self.lastRequestMsg = None
self.lastRequestUID = 0 self.lastRequestUID = 0
self.resumed = False
self.retriesCount = 0 self.retriesCount = 0
self.seqMatcher = difflib.SequenceMatcher(None) self.seqMatcher = difflib.SequenceMatcher(None)
self.shared = shared self.shared = shared

View File

@ -51,10 +51,11 @@ reqCount = 0
def __oneShotErrorUse(expression, field): def __oneShotErrorUse(expression, field):
global reqCount global reqCount
threadData = getCurrentThreadData()
retVal = conf.hashDB.retrieve(expression) if not any([conf.flushSession, conf.freshQueries]) else None retVal = conf.hashDB.retrieve(expression) if not any([conf.flushSession, conf.freshQueries]) else None
threadData = getCurrentThreadData()
threadData.resumed = retVal is not None
offset = 1 offset = 1
chunk_length = None chunk_length = None
@ -140,6 +141,8 @@ def __errorFields(expression, expressionFields, expressionFieldsList, expected=N
outputs = [] outputs = []
origExpr = None origExpr = None
threadData = getCurrentThreadData()
for field in expressionFieldsList: for field in expressionFieldsList:
output = None output = None
@ -171,7 +174,7 @@ def __errorFields(expression, expressionFields, expressionFieldsList, expected=N
if output is not None: if output is not None:
kb.locks.ioLock.acquire() kb.locks.ioLock.acquire()
dataToStdout("[%s] [INFO] retrieved: %s\r\n" % (time.strftime("%X"), safecharencode(output))) dataToStdout("[%s] [INFO] %s: %s\r\n" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", safecharencode(output)))
kb.locks.ioLock.release() kb.locks.ioLock.release()
if isinstance(num, int): if isinstance(num, int):

View File

@ -46,13 +46,15 @@ from lib.request.connect import Connect as Request
from lib.utils.resume import resume from lib.utils.resume import resume
reqCount = 0 reqCount = 0
resumed = False
def __oneShotUnionUse(expression, unpack=True, limited=False): def __oneShotUnionUse(expression, unpack=True, limited=False):
global reqCount global reqCount
retVal = conf.hashDB.retrieve(expression) if not any([conf.flushSession, conf.freshQueries]) else None retVal = conf.hashDB.retrieve(expression) if not any([conf.flushSession, conf.freshQueries]) else None
threadData = getCurrentThreadData()
threadData.resumed = retVal is not None
if retVal is None: if retVal is None:
check = "(?P<result>%s.*%s)" % (kb.chars.start, kb.chars.stop) check = "(?P<result>%s.*%s)" % (kb.chars.start, kb.chars.stop)
trimcheck = "%s(?P<result>.*?)</" % (kb.chars.start) trimcheck = "%s(?P<result>.*?)</" % (kb.chars.start)
@ -327,7 +329,7 @@ def unionUse(expression, unpack=True, dump=False):
items = output.replace(kb.chars.start, "").replace(kb.chars.stop, "").split(kb.chars.delimiter) items = output.replace(kb.chars.start, "").replace(kb.chars.stop, "").split(kb.chars.delimiter)
if conf.verbose == 1: if conf.verbose == 1:
status = "[%s] [INFO] retrieved: %s\r\n" % (time.strftime("%X"), safecharencode(",".join(map(lambda x: "\"%s\"" % x, items)))) status = "[%s] [INFO] %s: %s\r\n" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", safecharencode(",".join(map(lambda x: "\"%s\"" % x, items))))
if len(status) > width: if len(status) > width:
status = "%s..." % status[:width - 3] status = "%s..." % status[:width - 3]