[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH 1/2] Fixes contrib/gpsData.py for Python 3.
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] [PATCH 1/2] Fixes contrib/gpsData.py for Python 3. |
Date: |
Thu, 22 Sep 2016 18:46:44 -0700 |
Yo Fred!
Pushed and pulled. Thanks.
On Thu, 22 Sep 2016 16:29:29 -0700
Fred Wright <address@hidden> wrote:
> TESTED:
> Ran with all supported Python versions.
> ---
> contrib/gpsData.py | 47
> ++++++++++++++++++++++++++--------------------- 1 file changed, 26
> insertions(+), 21 deletions(-)
>
> diff --git a/contrib/gpsData.py b/contrib/gpsData.py
> index 807a270..a476961 100755
> --- a/contrib/gpsData.py
> +++ b/contrib/gpsData.py
> @@ -2,6 +2,11 @@
> # Written by Dan Mandle http://dan.mandle.me September 2012
> # http://www.danmandle.com/blog/getting-gpsd-to-work-with-python/
> # License: GPL 2.0
> +
> +# This code runs compatibly under Python 2 and 3.x for x >= 2.
> +# Preserve this property!
> +from __future__ import absolute_import, print_function, division
> +
> import os
> from gps import *
> from time import *
> @@ -23,7 +28,7 @@ class GpsPoller(threading.Thread):
> def run(self):
> global gpsd
> while gpsp.running:
> - gpsd.next() #this will continue to loop and grab EACH set of
> gpsd info to clear the buffer
> + next(gpsd) #this will continue to loop and grab EACH set of
> gpsd info to clear the buffer
> if __name__ == '__main__':
> gpsp = GpsPoller() # create the thread
> @@ -35,30 +40,30 @@ if __name__ == '__main__':
>
> os.system('clear')
>
> - print
> - print ' GPS reading'
> - print '----------------------------------------'
> - print 'latitude ' , gpsd.fix.latitude
> - print 'longitude ' , gpsd.fix.longitude
> - print 'time utc ' , gpsd.utc,' + ', gpsd.fix.time
> - print 'altitude (m)' , gpsd.fix.altitude
> - print 'eps ' , gpsd.fix.eps
> - print 'epx ' , gpsd.fix.epx
> - print 'epv ' , gpsd.fix.epv
> - print 'ept ' , gpsd.fix.ept
> - print 'speed (m/s) ' , gpsd.fix.speed
> - print 'climb ' , gpsd.fix.climb
> - print 'track ' , gpsd.fix.track
> - print 'mode ' , gpsd.fix.mode
> - print
> - print "%s satellites in view:" % len(gpsd.satellites)
> + print()
> + print(' GPS reading')
> + print('----------------------------------------')
> + print('latitude ' , gpsd.fix.latitude)
> + print('longitude ' , gpsd.fix.longitude)
> + print('time utc ' , gpsd.utc,' + ', gpsd.fix.time)
> + print('altitude (m)' , gpsd.fix.altitude)
> + print('eps ' , gpsd.fix.eps)
> + print('epx ' , gpsd.fix.epx)
> + print('epv ' , gpsd.fix.epv)
> + print('ept ' , gpsd.fix.ept)
> + print('speed (m/s) ' , gpsd.fix.speed)
> + print('climb ' , gpsd.fix.climb)
> + print('track ' , gpsd.fix.track)
> + print('mode ' , gpsd.fix.mode)
> + print()
> + print("%s satellites in view:" % len(gpsd.satellites))
> for sat in gpsd.satellites:
> - print " %r" % sat
> + print(" %r" % sat)
>
> time.sleep(5) #set to whatever
>
> except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
> - print "\nKilling Thread..."
> + print("\nKilling Thread...")
> gpsp.running = False
> gpsp.join() # wait for the thread to finish what it's doing
> - print "Done.\nExiting."
> + print("Done.\nExiting.")
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
pgpddZyaHrMxU.pgp
Description: OpenPGP digital signature