MPA: Added --plain option for output to text files (disables progress bars)

This commit is contained in:
Cas Cremers 2010-11-15 10:16:17 +01:00
parent b1f993a6c9
commit f97afc4a62

View File

@ -79,6 +79,9 @@ def parseArgs():
parser.add_option("-D","--debug",dest="debug",default=False,action="store_true", parser.add_option("-D","--debug",dest="debug",default=False,action="store_true",
help="Enable debugging features.") help="Enable debugging features.")
parser.add_option("-p","--plain",dest="plain",default=False,action="store_true",
help="Ensure plain output, e.g., no progress bars.")
return parser.parse_args() return parser.parse_args()
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -114,6 +117,7 @@ def getCorrectIsolatedClaims(protocolset,options=None):
correctclaims = [] correctclaims = []
goodprotocols = [] goodprotocols = []
if not OPTS.plain:
widgets = ['Scanning for claims that are correct in isolation: ', Percentage(), ' ', widgets = ['Scanning for claims that are correct in isolation: ', Percentage(), ' ',
Bar(marker='#',left='[',right=']') Bar(marker='#',left='[',right=']')
] ]
@ -129,9 +133,11 @@ def getCorrectIsolatedClaims(protocolset,options=None):
if claim.okay: if claim.okay:
correctclaims.append((protocol,claim.id)) correctclaims.append((protocol,claim.id))
count += 1 count += 1
pbar.update(count)
pbar.finish()
return (goodprotocols,correctclaims) return (goodprotocols,correctclaims)
if not OPTS.plain:
pbar.update(count)
if not OPTS.plain:
pbar.finish()
def verifyMPAlist(mpalist,claimid,options=None): def verifyMPAlist(mpalist,claimid,options=None):
@ -218,6 +224,7 @@ def findAllMPA(protocolset,maxcount=3,options="",mpaoptions=""):
(protocolset,correct) = getCorrectIsolatedClaims(protocolset,options) (protocolset,correct) = getCorrectIsolatedClaims(protocolset,options)
print "Investigating %i correct claims." % (len(correct)) print "Investigating %i correct claims." % (len(correct))
# For all these claims... # For all these claims...
if not OPTS.plain:
widgets = ['Scanning for MPA attacks: ', Percentage(), ' ', widgets = ['Scanning for MPA attacks: ', Percentage(), ' ',
Bar(marker='#',left='[',right=']') Bar(marker='#',left='[',right=']')
] ]
@ -232,7 +239,9 @@ def findAllMPA(protocolset,maxcount=3,options="",mpaoptions=""):
# Try to find multi-protocol attacks # Try to find multi-protocol attacks
findMPA(protocolset,protocol,claimid,maxcount,options=alloptions) findMPA(protocolset,protocol,claimid,maxcount,options=alloptions)
count += 1 count += 1
if not OPTS.plain:
pbar.update(count) pbar.update(count)
if not OPTS.plain:
pbar.finish() pbar.finish()
""" """