diff -r f440529b9606 -r cfb0607e5afc gpx_plot.py --- a/gpx_plot.py Sat May 23 16:51:16 2020 +0200 +++ b/gpx_plot.py Thu Jun 15 08:46:26 2023 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf8 -*- ''' @@ -46,7 +46,7 @@ # find gnuplot binary gnuPlotCmd = which (options.gnuplot) if not gnuPlotCmd: - print '***', options.gnuplot, 'does not exist or is not executable\n' + print ('***', options.gnuplot, 'does not exist or is not executable\n') parser.print_help () sys.exit () @@ -109,9 +109,9 @@ # import xml data from files if not os.path.exists (fname): - print fname, 'does not exist' + print (fname, 'does not exist') continue - print 'opening file', fname + print ('opening file', fname) infile = open (fname) tree = etree.parse(infile) infile.close() @@ -134,7 +134,7 @@ times = [datetime.datetime.strptime(trkpt.find(nsmap + 'time' ).text, timeformat) for trkpt in trkpts] except Exception as e: - print '-- trackpoint without time' + print ('-- trackpoint without time') times = None # save original trackseg for plotting @@ -147,12 +147,12 @@ sumy += y sumz += z - print 'segment %d, with %d points:' % (si, n) + print ('segment %d, with %d points:' % (si, n)) ntot += n tracks.append (tracksegs) npoints.append ((fname.replace ('_','\_'), ntot)) # underscore -> subscripts in gnuplot - print 'number of points in track %s = %d:' % (fname, ntot) + print ('number of points in track %s = %d:' % (fname, ntot)) latm, lonm, elesum = xyz_to_latlonele (sumx, sumy, sumz) @@ -179,9 +179,9 @@ from subprocess import Popen, PIPE try: - plot = Popen ([gnuPlotCmd], stdin=PIPE, stdout=PIPE, stderr=PIPE) + plot = Popen ([gnuPlotCmd], stdin=PIPE, stdout=PIPE, stderr=PIPE, text=True) except Exception as e: - print e, 'while executing', gnuPlotCmd + print (e, 'while executing', gnuPlotCmd) sys.exit () range = 'set xrange [%f:%f]\nset yrange [%f:%f]\n' % (xmin, xmax, ymin, ymax) @@ -193,4 +193,4 @@ plot.stdin.write ("\n".join (data)) plot.stdin.write ('\n') plot.stdin.flush () -raw_input ('press enter to exit program') +input ('press enter to exit program')