From: <jb...@us...> - 2009-10-21 09:22:59
|
Revision: 371 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=371&view=rev Author: jblance Date: 2009-10-21 09:22:52 +0000 (Wed, 21 Oct 2009) Log Message: ----------- Added GPSBabel version check to plugin (in plugins-v2 branch) Modified Paths: -------------- pytrainer/branches/plugins-v2/plugins/garmin-hr/conf.xml pytrainer/branches/plugins-v2/plugins/garmin-hr/garminhr.py Modified: pytrainer/branches/plugins-v2/plugins/garmin-hr/conf.xml =================================================================== --- pytrainer/branches/plugins-v2/plugins/garmin-hr/conf.xml 2009-10-21 07:40:17 UTC (rev 370) +++ pytrainer/branches/plugins-v2/plugins/garmin-hr/conf.xml 2009-10-21 09:22:52 UTC (rev 371) @@ -1,9 +1,9 @@ <?xml version="1.0" ?> <pytrainer-plugin - name="Garmin Heart Rate" - description="Import yor records direclty from your garmin gps device with heart rate support" + name="Garmin via GPSBabel 1.3.5" + description="Import your records directly from your Garmin GPS device (e.g. Forerunner 205 or 305) using GPSBabel (version 1.3.5)" plugincode="garminhr" - pluginbutton="Import from Garmin (HR support)" + pluginbutton="Import from Garmin GPS device (via GPSBabel)" executable="garminhr" > <conf-values variable="device" value="usb:"/> Modified: pytrainer/branches/plugins-v2/plugins/garmin-hr/garminhr.py =================================================================== --- pytrainer/branches/plugins-v2/plugins/garmin-hr/garminhr.py 2009-10-21 07:40:17 UTC (rev 370) +++ pytrainer/branches/plugins-v2/plugins/garmin-hr/garminhr.py 2009-10-21 09:22:52 UTC (rev 371) @@ -20,6 +20,7 @@ import os, sys import logging from lxml import etree +from lib.xmlUtils import XMLParser import commands @@ -40,10 +41,12 @@ def run(self): logging.debug(">>") importfiles = [] - if self.garminDeviceExists(): + if not self.checkGPSBabelVersion("1.3.5"): + #TODO Remove Zenity below + os.popen("zenity --error --text='Must be using version 1.3.5 of GPSBabel for this plugin'"); + elif self.garminDeviceExists(): try: gpsbabelOutputFile = "%s/file.gtrnctr" % (self.tmpdir) - testInputFile = "/home/johnb/garmin/2009.07.26\ 143201.TCX" #TODO Remove Zenity below outgps = commands.getstatusoutput("gpsbabel -t -i garmin -f %s -o gtrnctr -F %s | zenity --progress --pulsate --text='Loading Data' auto-close" % (self.input_dev, gpsbabelOutputFile) ) if outgps[0]==0: @@ -72,8 +75,26 @@ logging.debug("<<") return importfiles + def checkGPSBabelVersion(self, validVersion): + result = commands.getstatusoutput('gpsbabel -V') + if result[0] == 0: + version = result[1].split() + try: + if version[2] == validVersion: + return True + else: + print "GPSBabel at version %s instead of expected version %s" % (version[2], validVersion) + except: + print "Unexpected result from gpsbabel -V" + return False + return False def garminDeviceExists(self): + info = XMLParser(self.data_path+"/conf.xml") + prefs = info.getAllValues("conf-values") + for (variable, value) in prefs: + if variable == "device": + self.input_dev = value try: outmod = commands.getstatusoutput('/sbin/lsmod | grep garmin_gps') if outmod[0]==256: #there is no garmin_gps module loaded This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |