Changeset 713b56e for src


Ignore:
Timestamp:
Sep 21, 2017, 7:32:01 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
0.5, debian/bullseye, debian/jessie, master
Children:
873002d
Parents:
9773514
Message:

Fixed python errors related to the conversion to str.format()

Location:
src/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/python/bin/gnuboat

    r9773514 r713b56e  
    3131import pynmea2
    3232import traceback
     33import math
    3334
    3435from gnuboat import daemon
    … …  
    106107        nmeafile.write('{}{}\r\n'.format(logsystemtime, str(pynmea2.RMC('GN', 'RMC',
    107108                                                     (gpsTime.strftime("%H%M%S"), gpsStatus,
    108                                                      '{:02d}{:s}'.format(latitude['degrees'], latitude['minutes']),
     109                                                     '{:02d}{}'.format(latitude['degrees'], latitude['minutes']),
    109110                                                     latitudeDirection,
    110                                                      '{:03d}{:s}'.format(longitude['degrees'], longitude['minutes']),
     111                                                     '{:03d}{}'.format(longitude['degrees'], longitude['minutes']),
    111112                                                     longitudeDirection,
    112113                                                     '{:04.1f}'.format(speedOverGround), '{:04.1f}'.format(courseOverGround),
    … …  
    120121
    121122def degreesDecimalToNmea(decimalDegrees):
    122     degrees = math.floor(decimalDegrees)
     123    degrees = int(math.floor(decimalDegrees))
    123124    minutes = 60.0 * (decimalDegrees - degrees)
    124125    return { 'degrees': degrees, 'minutes': minutes}
    … …  
    213214
    214215            # update rrd database for the webservice
    215             daemon.rrd_update(rrdfile, 'N:{:s}:{:s}:{:s}:{:s}:{:s}:{:s}:{:s}:{:s}'.format(
     216            daemon.rrd_update(rrdfile, 'N:{}:{}:{}:{}:{}:{}:{}:{}'.format(
    216217                latitude, longitude, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix))
    217218
  • src/python/gnuboat/daemon/gpsdpoller.py

    r9773514 r713b56e  
    4040        if self._currentValue == None or self.gpsFix() < 2:
    4141            return 0
    42         return self._currentValue.fix.latitude
     42        return self._currentValue.lat
    4343
    4444    def latitudeDirection(self):
    … …  
    4848        if self._currentValue == None or self.gpsFix() < 2:
    4949            return 0
    50         return self._currentValue.fix.longitude
     50        return self._currentValue.lon
    5151
    5252    def longitudeDirection(self):
    … …  
    5656        if self._currentValue == None or self.gpsFix() < 2:
    5757            return 0
    58         return self._currentValue.fix.speed
     58        return self._currentValue.speed
    5959
    6060    def courseOverGround(self):
    6161        if self._currentValue == None or self.gpsFix() < 2:
    6262            return 0
    63         return self._currentValue.fix.track
     63        return self._currentValue.track
    6464
    6565    def gpsFix(self):
    66         if self._currentValue == None:
     66        if self._currentValue == None or 'mode' not in self._currentValue:
    6767            return 0
    68         return self._currentValue.fix.mode
     68        return self._currentValue.mode
    6969
    7070    def status(self):
    … …  
    7676        if self._currentValue == None or self.gpsFix() < 2:
    7777            return None
    78         currentTime = self._currentValue.fix.time
     78        currentTime = self._currentValue.time
    7979        if isinstance(currentTime, float):
    8080            return datetime.datetime.fromtimestamp(currentTime)
    … …  
    9090                    if self._session is None:
    9191                        self._session = gps.gps(mode=gps.WATCH_ENABLE)
    92                     self._currentValue = self._session.next()
     92                    current_value = self._session.next()
     93                    # only update current value, if we got an epX entry
     94                    # dop entries are ignored right now
     95                    if 'mode' in current_value:
     96                        self._currentValue = current_value
    9397                except StopIteration:
    9498                    break
Note: See TracChangeset for help on using the changeset viewer.