File: gps_auto_update.py

package info (click to toggle)
python-easygui 0.98.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,492 kB
  • sloc: python: 3,242; makefile: 151; xml: 120
file content (44 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""

from:
http://stackoverflow.com/questions/24621288/getting-easygui-to-self-update-info

Use this to show how the new interface would be used

"""

import sys
if sys.version_info.major > 2:
    print("Sorry, the module gps is not included in Python 3") 
    sys.exit()

import gps
from easygui import *
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
while True:
     try:
          report = session.next()
          if report['class'] == 'TPV':
               if hasattr(report, 'time'):
                    hour = int(report.time[11:13])
                    hourfix = hour - 7
                    if hourfix < 12:
                         time = 'Current Time Is: ' + report.time[5:7] + '/' + report.time[8:10] + '/' + report.time[0:4] + ' ' + str(hourfix) + report.time[13:19] + ' am'
                    else:
                         hourfix = hourfix - 12
                         time =  'Current Time Is: ' + report.time[5:7] + '/' + report.time[8:10] + '/' + report.time[0:4] + ' ' + str(hourfix) + report.time[13:19] + ' pm'
          if report['class'] == 'TPV':
               if hasattr(report, 'speed'):
                    speed = int(report.speed * gps.MPS_TO_MPH)
                    strspeed = str(speed)
                    currentspeed = 'Current Speed Is: ' + strspeed + ' MPH'
                    msgbox(time + "\n" + currentspeed, "SPEEDO by Jono")
     except KeyError:
          pass
     except KeyboardInterrupt:
          quit()
     except StopIteration:
          session = None
          print("GPSD has terminated")