aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2013-02-04 15:16:10 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:03:46 +0100
commit53493b2f22bc2d491f7607672e1d07e588677efa (patch)
tree8b406395f5b5090d44d046333ef1e4cdbe832226 /tools
parent3629936c927edb75d2529ff82395f735375d4650 (diff)
downloadexternal_parameter-framework-53493b2f22bc2d491f7607672e1d07e588677efa.zip
external_parameter-framework-53493b2f22bc2d491f7607672e1d07e588677efa.tar.gz
external_parameter-framework-53493b2f22bc2d491f7607672e1d07e588677efa.tar.bz2
PFW: Correct log level coverage script
BZ: 85983 Restrict debug log print to debug log level. Change-Id: I78bb79909502035247f410e9900a560190ee0ad5 Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com> Reviewed-on: http://android.intel.com:8080/90085 Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com> Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/coverage.py44
1 files changed, 31 insertions, 13 deletions
diff --git a/tools/coverage.py b/tools/coverage.py
index 4e8494a..6b50c37 100755
--- a/tools/coverage.py
+++ b/tools/coverage.py
@@ -816,26 +816,34 @@ class ArgumentParser:
def __init__(self):
try:
- # As argparse is only in the stdlib since python 3.2, testing its availability
+ # As argparse is only in the stdlib since python 3.2,
+ # testing its availability
import argparse
except ImportError:
- logger.warning("Unable to import argparse (argument parseur module), ")
+ logger.warning("Unable to import argparse "
+ "(parser for command-line options and arguments), ")
logger.warning("using default argument values:")
- self.inputFile = sys.stdin
logger.warning("InputFile: stdin")
+ self.inputFile = sys.stdin
- self.outputFile = sys.stdout
logger.warning("OutputFile: stdout")
+ self.outputFile = sys.stdout
- self.domainsFile = sys.argv[1]
- logger.warning("Domain file: " + self.domainsFile)
+ try:
+ self.domainsFile = sys.argv[1]
+ except IndexError as ex:
+ logger.fatal("No domain file provided (first argument)")
+ raise ex
+ else:
+ logger.warning("Domain file: " + self.domainsFile)
+ logger.warning("Output format: xml")
self.XMLreport = True
- logger.warning("OutputFormat: xml")
- self.debugLevel = 0
+ logger.warning("Debug level: error")
+ self.debugLevel = logging.WARNING
else :
myArgParser = argparse.ArgumentParser(description='Generate PFW report')
@@ -897,7 +905,15 @@ class ArgumentParser:
def main():
- commandLineArguments = ArgumentParser()
+ errorDuringLogParsing = -1
+ errorDuringArgumentParsing = 1
+
+ try:
+ commandLineArguments = ArgumentParser()
+ except LookupError as ex:
+ logger.error("Error during argument parsing")
+ logger.debug(str(ex))
+ sys.exit(errorDuringArgumentParsing)
# Setting logger level
logger.setLevel(commandLineArguments.debugLevel)
@@ -907,23 +923,25 @@ def main():
# Create tree from XML
dom = xml.dom.minidom.parse(commandLineArguments.domainsFile)
+ # Create element tree
root = Root("Coverage", dom)
+ # Parse PFW events
parser = ParsePFWlog(root.domains, root.criteria)
+
try:
parser.parsePFWlog(commandLineArguments.inputFile.readlines())
except Exception as ex:
- sys.stderr.write("Error during parsing log file %s:\n%s\n" %
+ logger.fatal("Error during parsing log file %s:\n%s\n" %
(commandLineArguments.inputFile, ex))
+ sys.exit(errorDuringLogParsing)
+ # Output report
outputFile = commandLineArguments.outputFile
if not commandLineArguments.XMLreport :
-
outputFile.write("%s\n" % root.dump(withCoverage=True, withNbUse=True))
-
else :
-
outputFile.write(root.exportToXML().toprettyxml())