From 1a4fce60e830f5bf05dc117f30ffdafff1897f1b Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 25 Jun 2014 15:25:29 -0700 Subject: [PATCH] tools: LogAnalyser, ensure error msgs go to stderr not stdout --- Tools/LogAnalyzer/DataflashLog.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tools/LogAnalyzer/DataflashLog.py b/Tools/LogAnalyzer/DataflashLog.py index 16f83561ca..69cd5e33f2 100644 --- a/Tools/LogAnalyzer/DataflashLog.py +++ b/Tools/LogAnalyzer/DataflashLog.py @@ -4,13 +4,13 @@ # Initial code by Andrew Chapman (amchapman@gmail.com), 16th Jan 2014 # +from __future__ import print_function import collections import os import numpy import bisect import sys - class Format: '''Data channel format as specified by the FMT lines in the log file''' msgType = 0 @@ -332,7 +332,7 @@ class DataflashLog: else: errorMsg = "Error parsing line %d of log file: %s" % (lineNumber, self.filename) if ignoreBadlines: - print errorMsg + " (skipping line)" + print(errorMsg + " (skipping line)", file=sys.stderr) self.skippedLines += 1 else: raise Exception("") @@ -372,7 +372,7 @@ class DataflashLog: if (len(tokens2)-1) != len(self.formats[groupName].labels): errorMsg = "%s line's value count (%d) not matching FMT specification (%d) on line %d" % (groupName, len(tokens2)-1, len(self.formats[groupName].labels), lineNumber) if ignoreBadlines: - print errorMsg + " (skipping line)" + print(errorMsg + " (skipping line)", file=sys.stderr) self.skippedLines += 1 continue else: @@ -386,6 +386,7 @@ class DataflashLog: channel.dictData[lineNumber] = value channel.listData.append((lineNumber,value)) except Exception as e: + print("BAD LINE: " + line, file=sys.stderr) raise Exception("Error parsing line %d of log file %s - %s" % (lineNumber,self.filename,e.args[0]))