From: <jb...@us...> - 2009-09-23 09:15:29
|
Revision: 349 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=349&view=rev Author: jblance Date: 2009-09-23 09:15:18 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Changes to allow sport addition on the fly, added importFromGPX function Modified Paths: -------------- pytrainer/branches/plugins-v2/pytrainer/record.py Modified: pytrainer/branches/plugins-v2/pytrainer/record.py =================================================================== --- pytrainer/branches/plugins-v2/pytrainer/record.py 2009-09-23 06:49:49 UTC (rev 348) +++ pytrainer/branches/plugins-v2/pytrainer/record.py 2009-09-23 09:15:18 UTC (rev 349) @@ -121,7 +121,7 @@ list_options["rcd_beats"] = 0 #retrieving sport id (adding sport if it doesn't exist yet) - sport_id = self.getSportId(list_options["rcd_sport"],add=None) + sport_id = self.getSportId(list_options["rcd_sport"],add=True) values= ( list_options["rcd_date"], @@ -276,12 +276,12 @@ sport_id = self.ddbb.select("sports","id_sports","name=\"%s\"" %(sport))[0][0] except: logging.error('Error retrieving id_sports from '+ str(sport)) - traceback.print_last() + #traceback.print_last() if add is None: logging.debug('Sport '+str(sport)+' will not be added to DB') else: logging.debug('Adding sport '+str(sport)+' to DB') - sport_id = self.addNewSport(self,sport,0,0) + sport_id = self.addNewSport(sport,"0","0") logging.debug('<<') return sport_id @@ -295,8 +295,8 @@ returns: id_sports from new sport""" logging.debug(">>") logging.debug("Adding new sport: "+sport+"|"+weight+"|"+met) - sport = [sport,met,weight] - self.ddbb.insert("sports","name,met,weight",sport) + sportT = [sport,met,weight] + self.ddbb.insert("sports","name,met,weight",sportT) sport_id = self.ddbb.select("sports","id_sports","name=\"%s\"" %(sport))[0][0] logging.debug("<<") return sport_id @@ -401,6 +401,18 @@ self.recordwindow.run() logging.debug('<<') + def importFromGPX(self, gpxFile): + """ + Add a record from a valid pytrainer type GPX file + """ + logging.debug('>>') + logging.info('Retrieving data from '+gpxFile) + #create an entry, defaulting sport to 'import' - in future could get actual sport from gpxFile.... + entry = ["import",""] + entry_id = self.insertNewRecord(gpxFile, entry) + logging.info('Entry '+str(entry_id)+' has been added') + logging.debug('<<') + def importFromGTRNCTR(self,gtrnctrFile): """22.03.2008 - dgranda Retrieves sport, date and start time from each entry coming from GPS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |