port faultspaceplot to python3

This commit is contained in:
Robin Thunig
2021-12-15 00:28:42 +01:00
parent e52ece5aed
commit da7af918c6
2 changed files with 18 additions and 18 deletions

View File

@ -100,9 +100,9 @@ if [ ! -z "$SYMBOLCSV" -a $(wc -l < $SYMBOLCSV) -gt 1 ]; then
mv "$SYMBOLCSV" "$KEPT" mv "$SYMBOLCSV" "$KEPT"
SYMBOLCSV=$KEPT SYMBOLCSV=$KEPT
fi fi
"$MYDIR"/fsp.plot.py "$COMPACTCSV" "$SYMBOLCSV" python3 "$MYDIR"/fsp.plot.py "$COMPACTCSV" "$SYMBOLCSV"
[ $KEEPCSV = no ] && rm "$SYMBOLCSV" [ $KEEPCSV = no ] && rm "$SYMBOLCSV"
else else
"$MYDIR"/fsp.plot.py "$COMPACTCSV" python3 "$MYDIR"/fsp.plot.py "$COMPACTCSV"
fi fi
[ $KEEPCSV = no ] && rm "$COMPACTCSV" [ $KEEPCSV = no ] && rm "$COMPACTCSV"

View File

@ -34,31 +34,31 @@ class Rectangle:
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Check provided arguments: # Check provided arguments:
if len(sys.argv) <= 1: if len(sys.argv) <= 1:
print "ERROR: Not enough arguments provided! See -h for more infos." print ("ERROR: Not enough arguments provided! See -h for more infos.")
exit(1) exit(1)
if sys.argv[1] == '-h': if sys.argv[1] == '-h':
print "Displays experiment results for the weather-monitor-experiment." print ("Displays experiment results for the weather-monitor-experiment.")
print " CALL-SYNTAX: fsp.plot.py DATA_FILE [USER_TAG_FILE]" print (" CALL-SYNTAX: fsp.plot.py DATA_FILE [USER_TAG_FILE]")
print "DATA_FILE is a CSV-file, storing the tab-separated values" print ("DATA_FILE is a CSV-file, storing the tab-separated values")
print "retrieved by the experiment run. USER_TAG_FILE is an optional" print ("retrieved by the experiment run. USER_TAG_FILE is an optional")
print "CSV-file which can be used to add user-specific marks to the" print ("CSV-file which can be used to add user-specific marks to the")
print "plot." # TODO: be more precise here print ("plot.") # TODO: be more precise here
exit(0) exit(0)
print "Opening and processing \"" + sys.argv[1] + "\"..." print ("Opening and processing \"" + sys.argv[1] + "\"...")
file = open(sys.argv[1], "r") file = open(sys.argv[1], "r")
dialect = csv.Sniffer().sniff(file.read(1024)) dialect = csv.Sniffer().sniff(file.read(1024))
file.seek(0) file.seek(0)
reader = csv.reader(file, dialect) reader = csv.reader(file, dialect)
reader.next() # Move down a line to skip the header next(reader) # Move down a line to skip the header
if len(sys.argv) >= 3: if len(sys.argv) >= 3:
print "Opening and processing \"" + sys.argv[2] + "\"..." print ("Opening and processing \"" + sys.argv[2] + "\"...")
symbolfile = open(sys.argv[2], "r") symbolfile = open(sys.argv[2], "r")
dialect = csv.Sniffer().sniff(symbolfile.read(1024)) dialect = csv.Sniffer().sniff(symbolfile.read(1024))
symbolfile.seek(0) symbolfile.seek(0)
symbolreader = csv.reader(symbolfile, dialect) symbolreader = csv.reader(symbolfile, dialect)
symbolreader.next() # Move down a line to skip the header next(symbolreader) # Move down a line to skip the header
have_symbols = True have_symbols = True
else: else:
have_symbols = False have_symbols = False
@ -75,8 +75,8 @@ for row in reader:
line_counter += 1 line_counter += 1
# Check if there are at least ENTRY_COUNT_PER_LINE entries per line: # Check if there are at least ENTRY_COUNT_PER_LINE entries per line:
if len(row) != ENTRY_COUNT_PER_LINE: if len(row) != ENTRY_COUNT_PER_LINE:
print "ERROR: Line " + str(line_counter) + " is invalid (" +\ print ("ERROR: Line " + str(line_counter) + " is invalid (" +\
str(ENTRY_COUNT_PER_LINE) + " entries expected)" str(ENTRY_COUNT_PER_LINE) + " entries expected)")
sys.exit(1) sys.exit(1)
# Some constants to access the row-entries much easier: # Some constants to access the row-entries much easier:
@ -138,13 +138,13 @@ if have_symbols:
if (address >= ymin) and (address <= ymax): if (address >= ymin) and (address <= ymax):
ticks.append(address) ticks.append(address)
symbols.append(row[IDX_SYMBOL_NAME]) symbols.append(row[IDX_SYMBOL_NAME])
#print "symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME] #print ("symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME])
elif (address < ymin) and (address + size >= ymin): elif (address < ymin) and (address + size >= ymin):
ticks.append(ymin) ticks.append(ymin)
symbols.append("(" + row[IDX_SYMBOL_NAME] + ")") symbols.append("(" + row[IDX_SYMBOL_NAME] + ")")
#print "partial symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME] #print ("partial symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME])
else: else:
#print "skipped symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME] #print ("skipped symbol: " + str(address) + " " + str(size) + " " + row[IDX_SYMBOL_NAME])
pass pass
# list of interesting addresses # list of interesting addresses