|
From: <dg...@us...> - 2009-03-25 18:01:04
|
Revision: 295
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=295&view=rev
Author: dgranda
Date: 2009-03-25 18:00:55 +0000 (Wed, 25 Mar 2009)
Log Message:
-----------
Cosmetic changes regarding var names and logging
Modified Paths:
--------------
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/plugins.py
pytrainer/trunk/pytrainer/record.py
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-03-25 17:54:16 UTC (rev 294)
+++ pytrainer/trunk/pytrainer/main.py 2009-03-25 18:00:55 UTC (rev 295)
@@ -256,6 +256,7 @@
logging.debug('>>')
selected,iter = self.windowmain.recordTreeView.get_selection().get_selected()
id_record = selected.get_value(iter,0)
+ logging.debug('Trying to show map for record '+str(id_record))
self.windowmain.actualize_map(id_record)
logging.debug('<<')
@@ -383,6 +384,7 @@
if version_tmp<="1.5.0.1":
self.ddbb.addweightandmet2ddbb()
if version_tmp<="1.5.0.2":
+ logging.info('Adding maxspeed, maxpace, pace and maxbeats columns')
self.ddbb.addpaceandmax2ddbb()
if version_tmp < "1.6.0.1":
logging.info('Adding date_time_utc column and retrieving data from local GPX files')
Modified: pytrainer/trunk/pytrainer/plugins.py
===================================================================
--- pytrainer/trunk/pytrainer/plugins.py 2009-03-25 17:54:16 UTC (rev 294)
+++ pytrainer/trunk/pytrainer/plugins.py 2009-03-25 18:00:55 UTC (rev 295)
@@ -17,6 +17,7 @@
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
+import logging
from lib.xmlUtils import XMLParser
from lib.system import checkConf
@@ -36,24 +37,28 @@
return retorno
def loadPlugin(self,plugin):
+ logging.debug('>>')
info = XMLParser(plugin+"/conf.xml")
button = info.getValue("pytrainer-plugin","pluginbutton")
name = info.getValue("pytrainer-plugin","name")
- print "Loading Plugin %s" %name
+ logging.info('Loading plugin '+name)
+ logging.debug('<<')
return button,plugin
def runPlugin(self,pathPlugin):
+ logging.debug('>>')
info = XMLParser(pathPlugin+"/conf.xml")
bin = info.getValue("pytrainer-plugin","executable")
- binnary = pathPlugin+"/"+bin
+ binary = pathPlugin+"/"+bin
params = ""
for opt in self.getPluginConfParams(pathPlugin):
if opt[0]!="status":
params += " --%s %s" %(opt[0],opt[1])
- print "%s %s" %(binnary,params)
- gpxfile = os.popen("%s %s" %(binnary,params)).read()
+ logging.debug('Executing '+binary+' '+params)
+ gpxfile = os.popen("%s %s" %(binary,params)).read()
gpxfile = gpxfile.replace("\n","")
gpxfile = gpxfile.replace("\r","")
+ logging.debug('<<')
if gpxfile == "0":
return False
return gpxfile
Modified: pytrainer/trunk/pytrainer/record.py
===================================================================
--- pytrainer/trunk/pytrainer/record.py 2009-03-25 17:54:16 UTC (rev 294)
+++ pytrainer/trunk/pytrainer/record.py 2009-03-25 18:00:55 UTC (rev 295)
@@ -220,7 +220,7 @@
logging.debug('<<')
def parseFloatRecord(self,string):
- logging.debug('>>')
+ logging.debug('--')
if string != "":
try:
return float(string.replace(",",","))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jli...@us...> - 2009-04-03 06:18:07
|
Revision: 311
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=311&view=rev
Author: jliljenfeldt
Date: 2009-04-03 06:18:02 +0000 (Fri, 03 Apr 2009)
Log Message:
-----------
Could not import while using MySQL. freeexec did not work and datetime.date objects seems to need explicit conversion to strings.
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/lib/mysqlUtils.py
pytrainer/trunk/pytrainer/record.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-02 21:44:35 UTC (rev 310)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-03 06:18:02 UTC (rev 311)
@@ -190,7 +190,7 @@
self.record_maxpace.set_text("%0.2f" %maxpace)
self.record_sport.set_text(sport)
- self.record_date.set_text(date)
+ self.record_date.set_text(date.isoformat())
hour,min,sec=self.parent.date.second2time(int(record_list[3]))
self.record_hour.set_text("%d" %hour)
self.record_minute.set_text("%d" %min)
@@ -306,7 +306,7 @@
self.day_pace.set_text(pace)
self.day_maxpace.set_text(maxpace)
self.day_calories.set_text("%0.0f" %calories)
- self.day_topic.set_text(record[1])
+ self.day_topic.set_text(record[1].isoformat())
else:
self.dayview.set_sensitive(0)
Modified: pytrainer/trunk/pytrainer/lib/mysqlUtils.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/mysqlUtils.py 2009-04-02 21:44:35 UTC (rev 310)
+++ pytrainer/trunk/pytrainer/lib/mysqlUtils.py 2009-04-03 06:18:02 UTC (rev 311)
@@ -18,7 +18,9 @@
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-import _mysql
+#import _mysql
+import MySQLdb
+from logs import Log
# Fixed some issues with MySql tables creation (email from Jonas Liljenfeldt)
class Sql:
@@ -28,13 +30,14 @@
self.ddbb_host = host
self.ddbb = ddbb
self.db = None
+ self.log = Log()
def connect(self):
#si devolvemos 1 ha ido todo con exito
#con 0 es que no estaba la bbdd creada
#con -1 imposible conectar a la maquina.
try:
- self.db=_mysql.connect(
+ self.db=MySQLdb.connect(
host=self.ddbb_host,
user=self.ddbb_user,
passwd=self.ddbb_pass,
@@ -130,7 +133,15 @@
self.db.query("""insert into %s (%s) values (%s)""" %(table,cells,string))
def freeExec(self,sql):
- self.db.query(sql)
+ #self.db.query(sql)
+ self.log.run(sql)
+ cur = self.db.cursor()
+ cur.execute(sql)
+ retorno = []
+ for row in cur.fetchall():
+ retorno.append(row)
+ self.db.commit()
+ return retorno
def delete(self,table,condition):
sql = "delete from %s where %s" %(table,condition)
Modified: pytrainer/trunk/pytrainer/record.py
===================================================================
--- pytrainer/trunk/pytrainer/record.py 2009-04-02 21:44:35 UTC (rev 310)
+++ pytrainer/trunk/pytrainer/record.py 2009-04-03 06:18:02 UTC (rev 311)
@@ -324,8 +324,8 @@
logging.debug('Found '+str(len(records))+' entries')
day_list = []
for i in records:
- record = i[0].split("-")
- logging.debug('date:'+i[0])
+ record = i[0].isoformat().split("-")
+ logging.debug('date:'+i[0].isoformat())
day_list.append(record[2])
logging.debug('<<')
return day_list
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jli...@us...> - 2009-04-03 16:59:57
|
Revision: 312
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=312&view=rev
Author: jliljenfeldt
Date: 2009-04-03 16:59:52 +0000 (Fri, 03 Apr 2009)
Log Message:
-----------
Explicit string casting of potential datetime.date object. Not using datetime.date methods anymore, like isoformat(), that would brake sqlite support.
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/record.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-03 06:18:02 UTC (rev 311)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-03 16:59:52 UTC (rev 312)
@@ -190,7 +190,7 @@
self.record_maxpace.set_text("%0.2f" %maxpace)
self.record_sport.set_text(sport)
- self.record_date.set_text(date.isoformat())
+ self.record_date.set_text(date)
hour,min,sec=self.parent.date.second2time(int(record_list[3]))
self.record_hour.set_text("%d" %hour)
self.record_minute.set_text("%d" %min)
@@ -306,7 +306,7 @@
self.day_pace.set_text(pace)
self.day_maxpace.set_text(maxpace)
self.day_calories.set_text("%0.0f" %calories)
- self.day_topic.set_text(record[1].isoformat())
+ self.day_topic.set_text(str(record[1]))
else:
self.dayview.set_sensitive(0)
Modified: pytrainer/trunk/pytrainer/record.py
===================================================================
--- pytrainer/trunk/pytrainer/record.py 2009-04-03 06:18:02 UTC (rev 311)
+++ pytrainer/trunk/pytrainer/record.py 2009-04-03 16:59:52 UTC (rev 312)
@@ -324,8 +324,8 @@
logging.debug('Found '+str(len(records))+' entries')
day_list = []
for i in records:
- record = i[0].isoformat().split("-")
- logging.debug('date:'+i[0].isoformat())
+ record = str(i[0]).split("-")
+ logging.debug('date:'+str(i[0]))
day_list.append(record[2])
logging.debug('<<')
return day_list
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dg...@us...> - 2009-04-19 10:32:17
|
Revision: 324
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=324&view=rev
Author: dgranda
Date: 2009-04-19 10:32:07 +0000 (Sun, 19 Apr 2009)
Log Message:
-----------
Logging improved
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/recordgraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-04-18 20:26:19 UTC (rev 323)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-04-19 10:32:07 UTC (rev 324)
@@ -23,28 +23,41 @@
from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar
from matplotlib.numerix import *
from pylab import *
+import logging
class DrawArea:
def __init__(self, vbox = None):
+ logging.debug('>>')
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.vbox = vbox
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.drawDefault()
+ logging.debug('<<')
def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
+ logging.debug('>>')
if len(xvalues[0]) < 1:
self.drawDefault()
return False
+ logging.debug('xvalues: '+str(xvalues))
+ logging.debug('yvalues: '+str(yvalues))
+ logging.debug('xlabel: '+str(xlabel))
+ logging.debug('ylabel: '+str(ylabel))
+ logging.debug('title: '+str(title))
+ logging.debug('color: '+str(color))
+ logging.debug('zones: '+str(zones))
if type == "bars":
self.drawBars(xvalues,yvalues,xlabel,ylabel,title,color)
elif type == "plot":
self.drawPlot(xvalues,yvalues,xlabel,ylabel,title,color,zones)
elif type == "pie":
self.drawPie(xvalues,yvalues,xlabel,ylabel,title,color,zones)
+ logging.debug('<<')
def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color):
- self.canvas.destroy()
+ logging.debug('>>')
+ self.canvas.destroy()
self.figure = Figure(figsize=(6,4), dpi=72)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.axis.clear()
@@ -52,55 +65,60 @@
i=0
for value in xvalues:
if len(xvalues) == 1:
- self.axis = self.figure.add_subplot(111)
+ self.axis = self.figure.add_subplot(111)
else:
- self.axis =self.figure.add_subplot(211 + i)
- self.axis.set_xlim(-width,len(xvalues[i]))
+ self.axis =self.figure.add_subplot(211 + i)
+ self.axis.set_xlim(-width,len(xvalues[i]))
self.axis.set_xlabel(xlabel[i])
self.axis.set_ylabel(ylabel[i])
- self.axis.set_title(title[i])
+ self.axis.set_title(title[i])
+ p1 = self.axis.bar(xvalues[i], yvalues[i], width, color=color[i])
+ i+=1
- p1 = self.axis.bar(xvalues[i], yvalues[i], width, color=color[i])
- i+=1
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ self.canvas.show()
+ self.vbox.pack_start(self.canvas, True, True)
+ logging.debug('<<')
def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
- self.canvas.destroy()
+ logging.debug('>>')
+ self.canvas.destroy()
self.figure = Figure(figsize=(6,4), dpi=72)
- #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
+ #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.axis.clear()
i = 0
for value in xvalues:
if len(xvalues) == 1:
- self.axis = self.figure.add_subplot(111)
+ self.axis = self.figure.add_subplot(111)
else:
- self.axis =self.figure.add_subplot(211 + i)
+ self.axis =self.figure.add_subplot(211 + i)
self.axis.set_xlabel(xlabel[i])
self.axis.set_ylabel(ylabel[i])
self.axis.set_title(title[i])
- self.axis.grid(True)
- self.axis.plot(xvalues[i],yvalues[i], color=color[i])
+ self.axis.grid(True)
+ self.axis.plot(xvalues[i],yvalues[i], color=color[i])
i+=1
+
if zones!=None:
for zone in zones:
- p = self.axis.axhspan(zone[0], zone[1], facecolor=zone[2], alpha=0.5, label=zone[3])
+ p = self.axis.axhspan(zone[0], zone[1], facecolor=zone[2], alpha=0.5, label=zone[3])
l = self.axis.legend(loc='lower right')
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ self.vbox.pack_start(self.canvas, True, True)
if title[0] == 'Stage Profile':
self.figure.savefig('/tmp/stage.png', dpi=75)
if title[0] == 'Heart Rate':
self.figure.savefig('/tmp/hr.png', dpi=75)
+ logging.debug('<<')
def drawPie(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
- self.canvas.destroy()
+ logging.debug('>>')
+ self.canvas.destroy()
self.figure = Figure(figsize=(6,4), dpi=72)
- #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
+ #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.axis.clear()
- self.axis = self.figure.add_subplot(111)
+ self.axis = self.figure.add_subplot(111)
labels = ["rest"]
colors = ["#ffffff"]
@@ -134,40 +152,44 @@
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ self.vbox.pack_start(self.canvas, True, True)
+ logging.debug('<<')
def drawDefault(self):
- #self.axis.clear()
- self.axis=self.figure.add_subplot(111)
- self.axis.set_xlabel('Yepper')
- self.axis.set_ylabel('Flabber')
- self.axis.set_title('An Empty Graph')
- self.axis.grid(True)
- self.canvas.destroy()
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ logging.debug('>>')
+ self.axis=self.figure.add_subplot(111)
+ self.axis.set_xlabel('Yepper')
+ self.axis.set_ylabel('Flabber')
+ self.axis.set_title('An Empty Graph')
+ self.axis.grid(True)
+ self.canvas.destroy()
+ self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
+ self.canvas.show()
+ self.vbox.pack_start(self.canvas, True, True)
+ logging.debug('<<')
def fill_over(self, ax, x, y, val, color, over=True):
- """
- Plot filled x,y for all y over val
- if over = False, fill all areas < val
- """
- ybase = asarray(y)-val
- crossings = nonzero(less(ybase[:-1] * ybase[1:],0))
+ """
+ Plot filled x,y for all y over val
+ if over = False, fill all areas < val
+ """
+ logging.debug('>>')
+ ybase = asarray(y)-val
+ crossings = nonzero(less(ybase[:-1] * ybase[1:],0))
- if ybase[0]>=0: fillon = over
- else: fillon = not over
+ if ybase[0]>=0:
+ fillon = over
+ else:
+ fillon = not over
+ indLast = 0
+ for ind in crossings:
+ if fillon:
+ thisX = x[indLast:ind+1]
+ thisY = y[indLast:ind+1]
+ thisY[0] = val
+ thisY[-1] = val
+ ax.fill(thisX, thisY, color)
+ fillon = not fillon
+ indLast = ind
+ logging.debug('<<')
-
- indLast = 0
- for ind in crossings:
- if fillon:
- thisX = x[indLast:ind+1]
- thisY = y[indLast:ind+1]
- thisY[0] = val
- thisY[-1] = val
- ax.fill(thisX, thisY, color)
- fillon = not fillon
- indLast = ind
-
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-18 20:26:19 UTC (rev 323)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-04-19 10:32:07 UTC (rev 324)
@@ -112,14 +112,15 @@
self.googlemaps = Googlemaps(self.data_path, self.map_vbox,waypoint)
def updateSportList(self,listSport):
+ logging.debug(">>")
self.sportlist.set_active(1)
while (self.sportlist.get_active() == 1):
self.sportlist.remove_text(1)
self.sportlist.set_active(1)
-
for i in listSport:
self.sportlist.append_text(i[0])
self.sportlist.set_active(0)
+ logging.debug("<<")
def create_treeview(self,treeview,column_names):
i=0
@@ -211,6 +212,7 @@
self.record_vbox.set_sensitive(1)
else:
self.record_vbox.set_sensitive(0)
+ #logging.debug("Going to draw "+str(record_list))
self.drawarearecord.drawgraph(record_list)
logging.debug("<<")
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-04-18 20:26:19 UTC (rev 323)
+++ pytrainer/trunk/pytrainer/main.py 2009-04-19 10:32:07 UTC (rev 324)
@@ -140,7 +140,7 @@
logging.debug('>>')
activeplugins = self.plugins.getActivePlugins()
if (len(activeplugins)<1):
- print _("No Active Plugins")
+ logging.info("No active plugins")
else:
for plugin in activeplugins:
txtbutton = self.plugins.loadPlugin(plugin)
@@ -151,7 +151,7 @@
logging.debug('>>')
activeextensions = self.extension.getActiveExtensions()
if (len(activeextensions)<1):
- print _("No Active Extensions")
+ logging.info("No active extensions")
else:
for extension in activeextensions:
txtbutton = self.extension.loadExtension(extension)
Modified: pytrainer/trunk/pytrainer/recordgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/recordgraph.py 2009-04-18 20:26:19 UTC (rev 323)
+++ pytrainer/trunk/pytrainer/recordgraph.py 2009-04-19 10:32:07 UTC (rev 324)
@@ -16,15 +16,19 @@
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import logging
from gui.drawArea import DrawArea
class RecordGraph:
def __init__(self, vbox = None, combovalue = None, combovalue2 = None):
+ logging.debug(">>")
self.drawarea = DrawArea(vbox)
self.combovalue = combovalue
self.combovalue2 = combovalue2
+ logging.debug("<<")
def drawgraph(self,values):
+ logging.debug(">>")
xval = []
yval = []
xlab = []
@@ -63,9 +67,9 @@
xlab.append(xlabel)
ylab.append(ylabel)
tit.append("")
- col.append(color)
-
+ col.append(color)
self.drawarea.stadistics("plot",xval,yval,xlab,ylab,tit,col)
+ logging.debug("<<")
def get_value_params(self,value):
if value == 0:
@@ -79,6 +83,7 @@
def get_values(self,values, value_selected):
+ logging.debug(">>")
xvalue = []
yvalue = []
for value in values:
@@ -94,6 +99,7 @@
yvalue.append(0)
if value_selected==3:
yvalue.append(value[6])
+ logging.debug("<<")
return xvalue,yvalue
def getFloatValue(self, value):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dg...@us...> - 2009-06-20 10:38:46
|
Revision: 331
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=331&view=rev
Author: dgranda
Date: 2009-06-20 10:38:44 +0000 (Sat, 20 Jun 2009)
Log Message:
-----------
Dirty fix for bug #2717135: widgets (graphs) not being destroyed properly, forcing removal
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/recordgraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-05-17 17:06:07 UTC (rev 330)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-06-20 10:38:44 UTC (rev 331)
@@ -29,24 +29,20 @@
def __init__(self, vbox = None):
logging.debug('>>')
self.figure = Figure(figsize=(6,4), dpi=72)
- self.axis = self.figure.add_subplot(111)
+ self.axis = self.figure.add_subplot(111)
self.vbox = vbox
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.drawDefault()
+ self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
+ #self.drawDefault()
logging.debug('<<')
def stadistics(self,type,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
if len(xvalues[0]) < 1:
- self.drawDefault()
+ #self.drawDefault()
return False
- logging.debug('xvalues: '+str(xvalues))
- logging.debug('yvalues: '+str(yvalues))
- logging.debug('xlabel: '+str(xlabel))
- logging.debug('ylabel: '+str(ylabel))
- logging.debug('title: '+str(title))
- logging.debug('color: '+str(color))
- logging.debug('zones: '+str(zones))
+ #logging.debug('xvalues: '+str(xvalues))
+ #logging.debug('yvalues: '+str(yvalues))
+ logging.info("Type: "+type+" | title: "+str(title)+" | col: "+str(color)+" | xlabel: "+str(xlabel)+" | ylabel: "+str(ylabel))
if type == "bars":
self.drawBars(xvalues,yvalues,xlabel,ylabel,title,color)
elif type == "plot":
@@ -58,6 +54,7 @@
def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color):
logging.debug('>>')
self.canvas.destroy()
+ self.vbox.remove(self.canvas)
self.figure = Figure(figsize=(6,4), dpi=72)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.axis.clear()
@@ -83,11 +80,12 @@
def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
self.canvas.destroy()
+ self.vbox.remove(self.canvas)
self.figure = Figure(figsize=(6,4), dpi=72)
- #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.axis.clear()
i = 0
for value in xvalues:
+ #logging.debug('xvalues: '+str(xvalues))
if len(xvalues) == 1:
self.axis = self.figure.add_subplot(111)
else:
@@ -115,6 +113,7 @@
def drawPie(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
self.canvas.destroy()
+ self.vbox.remove(self.canvas)
self.figure = Figure(figsize=(6,4), dpi=72)
#self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.axis.clear()
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-05-17 17:06:07 UTC (rev 330)
+++ pytrainer/trunk/pytrainer/main.py 2009-06-20 10:38:44 UTC (rev 331)
@@ -221,6 +221,7 @@
def refreshRecordGraphView(self, view):
logging.debug('>>')
+ logging.info('Working on '+view+' graph')
if view=="info":
selected,iter = self.windowmain.recordTreeView.get_selection().get_selected()
record_list=[]
Modified: pytrainer/trunk/pytrainer/recordgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/recordgraph.py 2009-05-17 17:06:07 UTC (rev 330)
+++ pytrainer/trunk/pytrainer/recordgraph.py 2009-06-20 10:38:44 UTC (rev 331)
@@ -36,7 +36,9 @@
tit = []
col = []
value_selected = self.combovalue.get_active()
+ logging.debug("Value selected 1: "+ str(value_selected))
value_selected2 = self.combovalue2.get_active()
+ logging.debug("Value selected 2: "+ str(value_selected2))
if value_selected < 0:
self.combovalue.set_active(0)
value_selected = 0
@@ -68,6 +70,7 @@
ylab.append(ylabel)
tit.append("")
col.append(color)
+ logging.info("To show: tit: "+str(tit)+" | col: "+str(col)+" | xlab: "+str(xlab)+" | ylab: "+str(ylab))
self.drawarea.stadistics("plot",xval,yval,xlab,ylab,tit,col)
logging.debug("<<")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vu...@us...> - 2009-06-29 21:36:08
|
Revision: 336
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=336&view=rev
Author: vud1
Date: 2009-06-29 21:35:50 +0000 (Mon, 29 Jun 2009)
Log Message:
-----------
"Experimental navigation bar in plot graphs"
Modified Paths:
--------------
pytrainer/trunk/pytrainer/daygraph.py
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/heartrategraph.py
pytrainer/trunk/pytrainer/monthgraph.py
pytrainer/trunk/pytrainer/recordgraph.py
pytrainer/trunk/pytrainer/yeargraph.py
Modified: pytrainer/trunk/pytrainer/daygraph.py
===================================================================
--- pytrainer/trunk/pytrainer/daygraph.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/daygraph.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -25,8 +25,6 @@
def drawgraph(self,values):
value_selected = self.combovalue.get_active()
- print "value selected "
- print value_selected
if value_selected < 0:
self.combovalue.set_active(0)
value_selected = 0
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -20,20 +20,21 @@
matplotlib.use('GTK')
from matplotlib.figure import Figure
from matplotlib.axes import Subplot
-from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar
+from matplotlib.backends.backend_gtk import FigureCanvasGTK
from matplotlib.numerix import *
import matplotlib.pyplot as plt
from pylab import *
import logging
-import numpy as np
+from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
class DrawArea:
- def __init__(self, vbox = None):
+ def __init__(self, vbox = None, window = None):
logging.debug('>>')
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.vbox = vbox
+ self.window = window
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.drawDefault()
logging.debug('<<')
@@ -82,9 +83,14 @@
def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
- self.canvas.destroy()
- self.vbox.remove(self.canvas)
- self.figure = plt.figure()
+ #self.canvas.destroy()
+ #self.vbox.remove(self.canvas)
+ for child in self.vbox.get_children():
+ if self.vbox.get_children()[0] != child:
+ self.vbox.remove(child)
+
+ #self.figure = plt.figure()
+ self.figure = Figure()
self.axis.clear()
i = 0
for value in xvalues:
@@ -106,6 +112,7 @@
ax2.plot(xvalues[i], yvalues[i], color=color[i])
for tl in ax2.get_yticklabels():
tl.set_color('%s' %color[i])
+ self.axis.set_xlabel(xlabel[i])
# axis2 = self.axis.twinx()
# axis2.plot(xvalues[i],yvalues[i], color=color[i])
#axis2.set_ylabel(ylabel[i],color=color[i])
@@ -121,6 +128,8 @@
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.vbox.pack_start(self.canvas, True, True)
+ toolbar = NavigationToolbar(self.canvas, self.window)
+ self.vbox.pack_start(toolbar, False, False)
if title[0] == 'Stage Profile':
self.figure.savefig('/tmp/stage.png', dpi=75)
if title[0] == 'Heart Rate':
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -101,12 +101,12 @@
self.parent.runExtension(extension,id)
def createGraphs(self,RecordGraph,DayGraph,MonthGraph,YearGraph,HeartRateGraph):
- self.drawarearecord = RecordGraph(self.record_vbox, self.record_combovalue, self.record_combovalue2)
- self.drawareaheartrate = HeartRateGraph(self.heartrate_vbox,self.heartrate_vbox2)
+ self.drawarearecord = RecordGraph(self.record_vbox, self.window1, self.record_combovalue, self.record_combovalue2)
+ self.drawareaheartrate = HeartRateGraph(self.heartrate_vbox, self.window1, self.heartrate_vbox2)
#self.drawareaday = DayGraph(self.day_vbox, self.day_combovalue)
self.day_vbox.hide()
- self.drawareamonth = MonthGraph(self.month_vbox, self.month_combovalue,self.month_combovalue2)
- self.drawareayear = YearGraph(self.year_vbox, self.year_combovalue,self.year_combovalue2)
+ self.drawareamonth = MonthGraph(self.month_vbox, self.window1, self.month_combovalue,self.month_combovalue2)
+ self.drawareayear = YearGraph(self.year_vbox, self.window1, self.year_combovalue,self.year_combovalue2)
def createMap(self,Googlemaps,waypoint):
self.googlemaps = Googlemaps(self.data_path, self.map_vbox,waypoint)
Modified: pytrainer/trunk/pytrainer/heartrategraph.py
===================================================================
--- pytrainer/trunk/pytrainer/heartrategraph.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/heartrategraph.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -22,9 +22,9 @@
from lib.heartrate import *
class HeartRateGraph:
- def __init__(self, vbox = None, vbox2 = None):
- self.drawarea = DrawArea(vbox)
- self.drawarea2 = DrawArea(vbox2)
+ def __init__(self, vbox = None, window = None, vbox2 = None):
+ self.drawarea = DrawArea(vbox, window)
+ self.drawarea2 = DrawArea(vbox2, window)
def drawgraph(self,values):
zones = getZones()
Modified: pytrainer/trunk/pytrainer/monthgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/monthgraph.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/monthgraph.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -19,8 +19,8 @@
from gui.drawArea import DrawArea
class MonthGraph:
- def __init__(self, vbox = None, combovalue = None, combovalue2 = None):
- self.drawarea = DrawArea(vbox)
+ def __init__(self, vbox = None, window = None, combovalue = None, combovalue2 = None):
+ self.drawarea = DrawArea(vbox, window)
self.combovalue = combovalue
self.combovalue2 = combovalue2
Modified: pytrainer/trunk/pytrainer/recordgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/recordgraph.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/recordgraph.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -20,9 +20,9 @@
from gui.drawArea import DrawArea
class RecordGraph:
- def __init__(self, vbox = None, combovalue = None, combovalue2 = None):
+ def __init__(self, vbox = None, window = None, combovalue = None, combovalue2 = None):
logging.debug(">>")
- self.drawarea = DrawArea(vbox)
+ self.drawarea = DrawArea(vbox, window)
self.combovalue = combovalue
self.combovalue2 = combovalue2
logging.debug("<<")
Modified: pytrainer/trunk/pytrainer/yeargraph.py
===================================================================
--- pytrainer/trunk/pytrainer/yeargraph.py 2009-06-28 17:54:03 UTC (rev 335)
+++ pytrainer/trunk/pytrainer/yeargraph.py 2009-06-29 21:35:50 UTC (rev 336)
@@ -19,8 +19,8 @@
from gui.drawArea import DrawArea
class YearGraph:
- def __init__(self, vbox = None, combovalue = None, combovalue2 = None):
- self.drawarea = DrawArea(vbox)
+ def __init__(self, vbox = None, window = None, combovalue = None, combovalue2 = None):
+ self.drawarea = DrawArea(vbox, window)
self.combovalue = combovalue
self.combovalue2 = combovalue2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vu...@us...> - 2009-06-30 21:54:04
|
Revision: 339
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=339&view=rev
Author: vud1
Date: 2009-06-30 21:54:01 +0000 (Tue, 30 Jun 2009)
Log Message:
-----------
"tool navigation bar for month and year graph"
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/recordgraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-06-30 17:39:27 UTC (rev 338)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-06-30 21:54:01 UTC (rev 339)
@@ -19,11 +19,10 @@
import matplotlib
matplotlib.use('GTK')
from matplotlib.figure import Figure
-from matplotlib.axes import Subplot
from matplotlib.backends.backend_gtk import FigureCanvasGTK
-from matplotlib.numerix import *
+#from matplotlib.numerix import *
import matplotlib.pyplot as plt
-from pylab import *
+#from pylab import *
import logging
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
@@ -31,11 +30,11 @@
class DrawArea:
def __init__(self, vbox = None, window = None):
logging.debug('>>')
- self.figure = Figure(figsize=(6,4), dpi=72)
- self.axis = self.figure.add_subplot(111)
+ #self.figure = Figure(figsize=(6,4), dpi=72)
+ #self.axis = self.figure.add_subplot(111)
self.vbox = vbox
self.window = window
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
+ #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
#self.drawDefault()
logging.debug('<<')
@@ -57,94 +56,109 @@
def drawBars(self,xvalues,yvalues,xlabel,ylabel,title,color):
logging.debug('>>')
- self.canvas.destroy()
- self.vbox.remove(self.canvas)
- self.figure = Figure(figsize=(6,4), dpi=72)
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.axis.clear()
- width = 1
+
+ for child in self.vbox.get_children():
+ if self.vbox.get_children()[0] != child:
+ self.vbox.remove(child)
+
+ figure = Figure(figsize=(6,4), dpi=72)
+ canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
+
+ xmod = 0.4
+ if len(xvalues) > 1:
+ width = 0.40
+ else:
+ width = 0.80
i=0
+
for value in xvalues:
- if len(xvalues) == 1:
- self.axis = self.figure.add_subplot(111)
- else:
- self.axis =self.figure.add_subplot(211 + i)
- self.axis.set_xlim(-width,len(xvalues[i]))
- self.axis.set_xlabel(xlabel[i])
- self.axis.set_ylabel(ylabel[i])
- self.axis.set_title(title[i])
- p1 = self.axis.bar(xvalues[i], yvalues[i], width, color=color[i])
+ if i<1:
+ axis = figure.add_subplot(111)
+ axis.set_xlim(-width,len(xvalues[i]))
+ axis.set_xlabel(xlabel[i])
+ axis.set_ylabel(ylabel[i])
+ axis.set_title(title[i])
+ j=0
+ for x in xvalues[i]:
+ xvalues[i][j]=x-xmod
+ j+=1
+ axis.bar(xvalues[i], yvalues[i], width, color=color[i])
+
+ axis.grid(True)
+ for tl in axis.get_yticklabels():
+ tl.set_color('%s' %color[i])
+ if i>=1:
+ ax2 = axis.twinx()
+ ax2.bar(xvalues[i], yvalues[i], width, color=color[i])
+ for tl in ax2.get_yticklabels():
+ tl.set_color('%s' %color[i])
+ axis.set_xlabel(xlabel[i])
i+=1
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ if (len(xvalues)>1):
+ axis.set_title("%s vs %s" %(ylabel[0],ylabel[1]))
+ else:
+ axis.set_title("%s" %(ylabel[0]))
+
+
+ canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
+ canvas.show()
+ self.vbox.pack_start(canvas, True, True)
+ toolbar = NavigationToolbar(canvas, self.window)
+ self.vbox.pack_start(toolbar, False, False)
logging.debug('<<')
def drawPlot(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
- #self.canvas.destroy()
- #self.vbox.remove(self.canvas)
+
for child in self.vbox.get_children():
if self.vbox.get_children()[0] != child:
self.vbox.remove(child)
- #self.figure = plt.figure()
- self.figure = Figure()
- self.axis.clear()
+ figure = Figure()
i = 0
for value in xvalues:
- if i==0:
- self.axis = self.figure.add_subplot(111)
- self.axis.plot(xvalues[i],yvalues[i], color=color[i])
- self.axis.set_xlabel(xlabel[i])
- #self.axis.set_ylabel(ylabel[i],color=color[i])
- if (len(xvalues)>1):
- self.axis.set_title("%s vs %s" %(ylabel[0],ylabel[1]))
- else:
- self.axis.set_title("%s" %(ylabel[0]))
+ if i<1:
+ axis = figure.add_subplot(111)
+ axis.plot(xvalues[i],yvalues[i], color=color[i])
- self.axis.grid(True)
- for tl in self.axis.get_yticklabels():
+ axis.grid(True)
+ for tl in axis.get_yticklabels():
tl.set_color('%s' %color[i])
- if i==1:
- ax2 = self.axis.twinx()
+ if i>=1:
+ ax2 = axis.twinx()
ax2.plot(xvalues[i], yvalues[i], color=color[i])
for tl in ax2.get_yticklabels():
tl.set_color('%s' %color[i])
- self.axis.set_xlabel(xlabel[i])
- # axis2 = self.axis.twinx()
- # axis2.plot(xvalues[i],yvalues[i], color=color[i])
- #axis2.set_ylabel(ylabel[i],color=color[i])
- #else:
- # self.axis =self.figure.add_subplot(211 + i)
+ axis.set_xlabel(xlabel[i])
i+=1
+
+ if (len(xvalues)>1):
+ axis.set_title("%s vs %s" %(ylabel[0],ylabel[1]))
+ else:
+ axis.set_title("%s" %(ylabel[0]))
-
- #if zones!=None:
- # for zone in zones:
- # p = self.axis.axhspan(zone[0], zone[1], facecolor=zone[2], alpha=0.5, label=zone[3])
- # l = self.axis.legend(loc='lower right')
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
- toolbar = NavigationToolbar(self.canvas, self.window)
+ canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
+ canvas.show()
+ self.vbox.pack_start(canvas, True, True)
+ toolbar = NavigationToolbar(canvas, self.window)
self.vbox.pack_start(toolbar, False, False)
if title[0] == 'Stage Profile':
- self.figure.savefig('/tmp/stage.png', dpi=75)
+ figure.savefig('/tmp/stage.png', dpi=75)
if title[0] == 'Heart Rate':
- self.figure.savefig('/tmp/hr.png', dpi=75)
+ figure.savefig('/tmp/hr.png', dpi=75)
logging.debug('<<')
def drawPie(self,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
- self.canvas.destroy()
- self.vbox.remove(self.canvas)
- self.figure = Figure(figsize=(6,4), dpi=72)
- #self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- #self.axis.clear()
- self.axis = self.figure.add_subplot(111)
+
+ for child in self.vbox.get_children():
+ if self.vbox.get_children()[0] != child:
+ self.vbox.remove(child)
+ figure = Figure(figsize=(6,4), dpi=72)
+ axis = figure.add_subplot(111)
+
labels = ["rest"]
colors = ["#ffffff"]
frac0 = 0
@@ -173,11 +187,11 @@
fracs = [frac0,frac1,frac2,frac3,frac4, frac5]
explode=(0, 0, 0, 0,0,0)
- self.axis.pie(fracs, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True)
+ axis.pie(fracs, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True)
- self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
- self.canvas.show()
- self.vbox.pack_start(self.canvas, True, True)
+ canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
+ canvas.show()
+ self.vbox.pack_start(canvas, True, True)
logging.debug('<<')
def drawDefault(self):
Modified: pytrainer/trunk/pytrainer/recordgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/recordgraph.py 2009-06-30 17:39:27 UTC (rev 338)
+++ pytrainer/trunk/pytrainer/recordgraph.py 2009-06-30 21:54:01 UTC (rev 339)
@@ -76,13 +76,13 @@
def get_value_params(self,value):
if value == 0:
- return _("Distance (km)"),_("Height (m)"),_("Stage Profile"),"#747400"
+ return _("Distance (km)"),_("Height (m)"),_("Stage Profile"),"#ff0000"
if value == 1:
- return _("Distance (km)"),_("Speed (Km/h)"),_("Speed"),"#007474"
+ return _("Distance (km)"),_("Speed (Km/h)"),_("Speed"),"#00ff00"
if value == 2:
- return _("Distance (km)"),_("Pace (min/km)"),_("Pace"),"#747400"
+ return _("Distance (km)"),_("Pace (min/km)"),_("Pace"),"#0000ff"
if value == 3:
- return _("Distance (km)"),_("Beats (bpm)"),_("Heart Rate"),"#740074"
+ return _("Distance (km)"),_("Beats (bpm)"),_("Heart Rate"),"#ff0000"
def get_values(self,values, value_selected):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dg...@us...> - 2009-07-21 17:31:59
|
Revision: 342
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=342&view=rev
Author: dgranda
Date: 2009-07-21 17:31:53 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Adding calories support suggested by JB
Modified Paths:
--------------
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/record.py
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-07-21 17:20:22 UTC (rev 341)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-07-21 17:31:53 UTC (rev 342)
@@ -57,6 +57,7 @@
self.maxvel = 0
self.maxhr = 0
self.date = ""
+ self.calories= 0
if filename != None:
if not os.path.isfile(self.filename):
return None
@@ -99,12 +100,20 @@
def getHeartRateAverage(self):
return self.hr_average
+
+ def getCalories(self):
+ return self.calories
def _getValues(self): # migrate to cElementTree
logging.debug(">>")
dom = self.dom
trkpoints = dom.getElementsByTagName("trkpt")
+ #start with the info at trkseg level
+ #calories - maybe more than one, currently adding them together
+ calorieCollection = dom.getElementsByTagName("gpxdata:calories")
+ for cal in calorieCollection:
+ self.calories += int(cal.firstChild.data)
retorno = []
his_vel = []
last_lat = "False"
Modified: pytrainer/trunk/pytrainer/record.py
===================================================================
--- pytrainer/trunk/pytrainer/record.py 2009-07-21 17:20:22 UTC (rev 341)
+++ pytrainer/trunk/pytrainer/record.py 2009-07-21 17:31:53 UTC (rev 342)
@@ -183,7 +183,8 @@
summaryRecord['rcd_gpxfile'] = gpxOrig
summaryRecord['rcd_sport'] = entry[0]
summaryRecord['rcd_date'] = gpx.getDate()
- summaryRecord['rcd_calories'] = '0.0' # not supported yet (29.03.2008)
+ summaryRecord['rcd_calories'] = gpx.getCalories()
+ logging.debug('rcd_calories: ' + str(summaryRecord['rcd_calories']))
summaryRecord['rcd_comments'] = ''
summaryRecord['rcd_title'] = ''
summaryRecord['rcd_time'] = time_hhmmss #ToDo: makes no sense to work with arrays
@@ -357,11 +358,13 @@
upositive,unegative = gpx.getUnevenness()
heartrate = gpx.getHeartRateAverage()
date = gpx.getDate()
+ calories = gpx.getCalories()
self.recordwindow.rcd_date.set_text(date)
self.recordwindow.rcd_upositive.set_text(str(upositive))
self.recordwindow.rcd_unegative.set_text(str(unegative))
self.recordwindow.rcd_beats.set_text(str(heartrate))
+ self.recordwindow.rcd_calories.set_text(str(calories))
self.recordwindow.set_distance(distance)
self.recordwindow.set_maxspeed(maxspeed)
self.recordwindow.set_maxhr(maxheartrate)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-08-08 10:48:39
|
Revision: 344
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=344&view=rev
Author: jblance
Date: 2009-08-08 10:48:27 +0000 (Sat, 08 Aug 2009)
Log Message:
-----------
Added dynamic loading and unloading of plugin menu items
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-08-03 17:39:15 UTC (rev 343)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-08-08 10:48:27 UTC (rev 344)
@@ -80,8 +80,14 @@
savedOptions.append(("calories","False"))
menufile.createXMLFile("listviewmenu",savedOptions)
+ def removeImportPlugin(self, plugin):
+ for widget in self.menuitem1_menu:
+ if widget.get_name() == plugin[1]:
+ self.menuitem1_menu.remove(widget)
+
def addImportPlugin(self,plugin):
button = gtk.MenuItem(plugin[0])
+ button.set_name(plugin[1])
button.connect("activate", self.parent.runPlugin, plugin[1])
self.menuitem1_menu.insert(button,2)
self.menuitem1_menu.show_all()
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-08-03 17:39:15 UTC (rev 343)
+++ pytrainer/trunk/pytrainer/main.py 2009-08-08 10:48:27 UTC (rev 344)
@@ -305,7 +305,21 @@
def editGpsPlugins(self):
logging.debug('>>')
+ activeplugins_before = self.plugins.getActivePlugins()
self.plugins.managePlugins()
+ activeplugins_after = self.plugins.getActivePlugins()
+ #Need to check for plugins that have been disabled (were active and now are not)
+ for plugin in activeplugins_before:
+ if plugin not in activeplugins_after:
+ #disabled plugin -> need to unload plugin
+ txtbutton = self.plugins.loadPlugin(plugin)
+ self.windowmain.removeImportPlugin(txtbutton)
+ #Need to check for plugins that have been enabled (were not active and now are)
+ for plugin in activeplugins_after:
+ if plugin not in activeplugins_before:
+ #new active plugin -> need to load plugin
+ txtbutton = self.plugins.loadPlugin(plugin)
+ self.windowmain.addImportPlugin(txtbutton)
logging.debug('<<')
def newRecord(self,title=None,distance=None,time=None,upositive=None,unegative=None,bpm=None,calories=None,date=None,comment=None):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dg...@us...> - 2009-11-12 19:31:25
|
Revision: 384
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=384&view=rev
Author: dgranda
Date: 2009-11-12 19:31:14 +0000 (Thu, 12 Nov 2009)
Log Message:
-----------
Improved logging
Modified Paths:
--------------
pytrainer/trunk/pytrainer/extensions/waypointeditor.py
pytrainer/trunk/pytrainer/heartrategraph.py
pytrainer/trunk/pytrainer/waypoint.py
Modified: pytrainer/trunk/pytrainer/extensions/waypointeditor.py
===================================================================
--- pytrainer/trunk/pytrainer/extensions/waypointeditor.py 2009-11-09 11:07:55 UTC (rev 383)
+++ pytrainer/trunk/pytrainer/extensions/waypointeditor.py 2009-11-12 19:31:14 UTC (rev 384)
@@ -27,25 +27,32 @@
import string,cgi,time
import time
+import logging
class WaypointEditor:
- def __init__(self, data_path = None, vbox = None, waypoint=None):
+ def __init__(self, data_path = None, vbox = None, waypoint=None):
+ logging.debug(">>")
self.data_path = data_path
self.conf = checkConf()
self.extension = Extension()
self.moz = gtkmozembed.MozEmbed()
- vbox.pack_start(self.moz, True, True)
+ vbox.pack_start(self.moz, True, True)
vbox.show_all()
self.htmlfile = ""
self.waypoint=waypoint
+ logging.debug("<<")
def drawMap(self):
+ logging.debug(">>")
#self.createHtml()
tmpdir = self.conf.getValue("tmpdir")
htmlfile = tmpdir+"/waypointeditor.html"
- self.moz.load_url("file://"+htmlfile)
+ logging.debug("HTML file: "+str(htmlfile))
+ self.moz.load_url("file://"+htmlfile)
+ logging.debug("<<")
def createHtml(self,default_waypoint=None):
+ logging.debug(">>")
tmpdir = self.conf.getValue("tmpdir")
filename = tmpdir+"/waypointeditor.html"
@@ -268,6 +275,6 @@
"""
file = fileUtils(filename,content)
file.run()
+ logging.debug("<<")
-
Modified: pytrainer/trunk/pytrainer/heartrategraph.py
===================================================================
--- pytrainer/trunk/pytrainer/heartrategraph.py 2009-11-09 11:07:55 UTC (rev 383)
+++ pytrainer/trunk/pytrainer/heartrategraph.py 2009-11-12 19:31:14 UTC (rev 384)
@@ -20,26 +20,34 @@
from lib.system import checkConf
from lib.xmlUtils import XMLParser
from lib.heartrate import *
+import logging
class HeartRateGraph:
def __init__(self, vbox = None, window = None, vbox2 = None):
+ logging.debug('>>')
self.drawarea = DrawArea(vbox, window)
self.drawarea2 = DrawArea(vbox2, window)
+ logging.debug('<<')
def drawgraph(self,values):
- zones = getZones()
-
+ logging.debug('>>')
+ zones = getZones()
xvalues, yvalues = self.get_values(values)
+ #logging.debug('xvalues: '+str(xvalues))
+ #logging.debug('yvalues: '+str(yvalues))
xlabel,ylabel,title,color = _("Distance (km)"),_("Beats (bpm)"),_("Heart Rate"),"#740074"
self.drawarea.stadistics("plot",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color],zones)
self.drawarea2.stadistics("pie",[xvalues],[yvalues],[xlabel],[ylabel],[title],[color],zones)
+ logging.debug('<<')
def get_values(self,values):
+ logging.debug('>>')
xvalue = []
yvalue = []
for value in values:
xvalue.append(value[0])
- yvalue.append(value[6])
+ yvalue.append(value[6])
+ logging.debug('<<')
return xvalue,yvalue
def getFloatValue(self, value):
Modified: pytrainer/trunk/pytrainer/waypoint.py
===================================================================
--- pytrainer/trunk/pytrainer/waypoint.py 2009-11-09 11:07:55 UTC (rev 383)
+++ pytrainer/trunk/pytrainer/waypoint.py 2009-11-12 19:31:14 UTC (rev 384)
@@ -20,40 +20,53 @@
from lib.system import checkConf
from lib.xmlUtils import XMLParser
+import logging
+
class Waypoint:
def __init__(self, data_path = None, parent = None):
+ logging.debug(">>")
self.parent = parent
self.data_path = data_path
self.conf = checkConf()
self.filename = self.conf.getValue("conffile")
self.configuration = XMLParser(self.filename)
self.ddbb = DDBB(self.configuration)
+ logging.debug("<<")
def removeWaypoint(self,id_waypoint):
+ logging.debug(">>")
self.ddbb.connect()
self.ddbb.delete("waypoints", "id_waypoint=\"%s\"" %id_waypoint)
self.ddbb.disconnect()
+ logging.debug("<<")
def updateWaypoint(self,id_waypoint,lat,lon,name,desc,sym):
+ logging.debug(">>")
self.ddbb.connect()
self.ddbb.update("waypoints","lat,lon,comment,name,sym",[lat,lon,desc,name,sym]," id_waypoint=%d" %id_waypoint)
self.ddbb.disconnect()
+ logging.debug("<<")
def getwaypointInfo(self,id_waypoint):
+ logging.debug(">>")
self.ddbb.connect()
retorno = self.ddbb.select("waypoint",
"lat,lon,ele,comment,time,name,sym"
"id_waypoint=\"%s\"" %id_waypoint)
self.ddbb.disconnect()
+ logging.debug("<<")
return retorno
def getAllWaypoints(self):
+ logging.debug(">>")
self.ddbb.connect()
retorno = self.ddbb.select("waypoints","id_waypoint,lat,lon,ele,comment,time,name,sym","1=1 order by name")
self.ddbb.disconnect()
+ logging.debug("<<")
return retorno
def actualize_fromgpx(self,gpxfile):
+ logging.debug(">>")
self.ddbb.connect()
from lib.gpx import Gpx
gpx = Gpx(self.data_path,gpxfile)
@@ -70,8 +83,10 @@
warning.set_text(msg)
warning.run()
self.ddbb.disconnect()
+ logging.debug("<<")
def _actualize_fromgpx(self, gpx):
+ logging.debug(">>")
distance, time = gpx.getMaxValues()
upositive,unegative = gpx.getUnevenness()
self.recordwindow.rcd_upositive.set_text(str(upositive))
@@ -79,4 +94,5 @@
self.recordwindow.set_distance(distance)
self.recordwindow.set_recordtime(time/60.0/60.0)
self.recordwindow.on_calcaverage_clicked(None)
+ logging.debug("<<")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-19 05:32:18
|
Revision: 390
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=390&view=rev
Author: jblance
Date: 2009-11-19 05:32:10 +0000 (Thu, 19 Nov 2009)
Log Message:
-----------
Fix for bug 2089342 auto refresh after import, edit and delete of records
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-18 19:19:47 UTC (rev 389)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-19 05:32:10 UTC (rev 390)
@@ -664,12 +664,12 @@
######################
def on_edit_clicked(self,widget):
- selected,iter = self.recordTreeView.get_selection().get_selected()
+ selected,iter = self.recordTreeView.get_selection().get_selected()
id_record = selected.get_value(iter,0)
self.parent.editRecord(id_record)
def on_remove_clicked(self,widget):
- selected,iter = self.recordTreeView.get_selection().get_selected()
+ selected,iter = self.recordTreeView.get_selection().get_selected()
id_record = selected.get_value(iter,0)
self.parent.removeRecord(id_record)
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-18 19:19:47 UTC (rev 389)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-19 05:32:10 UTC (rev 390)
@@ -185,6 +185,7 @@
logging.error('File '+pluginFile+' not valid')
else:
logging.debug("No files returned from Plugin")
+ self.refreshListRecords()
logging.debug('<<')
def runExtension(self,extension,id):
@@ -354,6 +355,7 @@
if date == None:
date = self.date.getDate()
self.record.newRecord(list_sport, date, title, distance, time, upositive, unegative, bpm, calories, comment)
+ self.refreshListRecords()
logging.debug('<<')
def editRecord(self, id_record):
@@ -361,6 +363,7 @@
list_sport = self.profile.getSportList()
logging.debug('id_record: '+str(id_record)+' | list_sport: '+str(list_sport))
self.record.editRecord(id_record,list_sport)
+ self.refreshListRecords()
logging.debug('<<')
def removeRecord(self, id_record, confirm = False):
@@ -373,6 +376,7 @@
warning = Warning(self.data_path,self.removeRecord,params)
warning.set_text(msg)
warning.run()
+ self.refreshListRecords()
logging.debug('<<')
def removeWaypoint(self,id_waypoint, confirm = False):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-20 06:44:09
|
Revision: 393
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=393&view=rev
Author: jblance
Date: 2009-11-20 06:44:01 +0000 (Fri, 20 Nov 2009)
Log Message:
-----------
Fix for weekview, start of week and localised days
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/lib/date.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/weekgraph.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-19 21:10:35 UTC (rev 392)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-20 06:44:01 UTC (rev 393)
@@ -339,7 +339,7 @@
def actualize_weekview(self, record_list, date_ini, date_end):
logging.debug(">>")
- self.drawareaweek.drawgraph(record_list)
+ self.drawareaweek.drawgraph(record_list, date_ini, date_end)
logging.debug("<<")
def actualize_monthview(self,record_list, nameMonth):
Modified: pytrainer/trunk/pytrainer/lib/date.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/date.py 2009-11-19 21:10:35 UTC (rev 392)
+++ pytrainer/trunk/pytrainer/lib/date.py 2009-11-20 06:44:01 UTC (rev 393)
@@ -20,6 +20,7 @@
import time
import datetime
+import calendar
class Date:
def __init__(self, calendar=None):
@@ -50,11 +51,19 @@
def time2string(self,date):
return "%0.4d-%0.2d-%0.2d" %(int(date[0]),int(date[1]),int(date[2]))
- def getWeekInterval(self,date):
- weekDate = datetime.datetime.strptime(date, "%Y-%m-%d")
- dayOfWeek = int(weekDate.strftime("%w"))
- date_ini = weekDate + datetime.timedelta(days=0-dayOfWeek)
- date_end = weekDate + datetime.timedelta(days=6-dayOfWeek)
+ def getWeekInterval(self,date, prf_us_system):
+ if prf_us_system == "True":
+ #Sunday is first day of week
+ weekDate = datetime.datetime.strptime(date, "%Y-%m-%d")
+ dayOfWeek = int(weekDate.strftime("%w"))
+ date_ini = weekDate + datetime.timedelta(days=0-dayOfWeek)
+ date_end = weekDate + datetime.timedelta(days=6-dayOfWeek)
+ else:
+ #Monday is first day of week
+ weekDate = datetime.datetime.strptime(date, "%Y-%m-%d")
+ dayOfWeek = int(weekDate.strftime("%w"))
+ date_ini = weekDate + datetime.timedelta(days=1-dayOfWeek)
+ date_end = weekDate + datetime.timedelta(days=7-dayOfWeek)
return date_ini.strftime("%Y-%m-%d"), date_end.strftime("%Y-%m-%d")
def getMonthInterval(self,date):
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-19 21:10:35 UTC (rev 392)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-20 06:44:01 UTC (rev 393)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9" # 22.10.2009
+ self.version ="1.6.0.9 svn" # 22.10.2009
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
@@ -111,6 +111,7 @@
self.filename = self.conf.getValue("conffile")
logging.debug('retrieving data from '+ self.filename)
self.configuration = XMLParser(self.filename)
+ self.prf_us_system = self.configuration.getValue("pytraining","prf_us_system")
self.ddbb = DDBB(self.configuration)
logging.debug('connecting to DDBB')
self.ddbb.connect()
@@ -222,7 +223,7 @@
selected,iter = self.windowmain.recordTreeView.get_selection().get_selected()
elif view=="week":
logging.debug('week view')
- date_ini, date_end = self.date.getWeekInterval(date_selected)
+ date_ini, date_end = self.date.getWeekInterval(date_selected, self.prf_us_system)
record_list = self.record.getrecordPeriod(date_ini, date_end)
self.windowmain.actualize_weekview(record_list, date_ini, date_end)
elif view=="month":
Modified: pytrainer/trunk/pytrainer/weekgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/weekgraph.py 2009-11-19 21:10:35 UTC (rev 392)
+++ pytrainer/trunk/pytrainer/weekgraph.py 2009-11-20 06:44:01 UTC (rev 393)
@@ -24,11 +24,17 @@
def __init__(self, vbox = None, window = None):
self.drawarea = DrawArea(vbox, window)
- def drawgraph(self,values):
+ def drawgraph(self,values, date_ini, date_end):
logging.debug(">>")
#print "Found %d records" % len(values)
logging.debug(str(values))
- days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+ #build days list to ensure localised values are used.
+ days = []
+ for day in range(0, 7):
+ dateTemp = datetime.datetime.strptime(date_ini, "%Y-%m-%d")
+ incrementDay = datetime.timedelta(days=day)
+ dateToUse = dateTemp + incrementDay
+ days.append( dateToUse.strftime("%a") )
valueDict = {}
for record in values:
day = datetime.datetime.strptime(record[1], "%Y-%m-%d").strftime("%a") # Gives Sun, Mon etc for this record
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-25 09:45:28
|
Revision: 403
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=403&view=rev
Author: jblance
Date: 2009-11-25 09:45:20 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Fix for week view to enable sport filtering
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/record.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-23 22:09:52 UTC (rev 402)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-25 09:45:20 UTC (rev 403)
@@ -941,7 +941,7 @@
if (sport > 0):
return self.sportlist.get_active_text()
else:
- return -1
+ return None
def quit(self, *args):
self.parent.quit()
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-23 22:09:52 UTC (rev 402)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-25 09:45:20 UTC (rev 403)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#401"
+ self.version ="1.6.0.9_svn#403"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
@@ -234,9 +234,8 @@
elif view=="week":
logging.debug('week view')
date_ini, date_end = self.date.getWeekInterval(date_selected, self.prf_us_system)
- #sport = self.windowmain.getSportSelected()
- #still need to fix for sport selection
- record_list = self.record.getrecordPeriod(date_ini, date_end)
+ sport = self.windowmain.getSportSelected()
+ record_list = self.record.getrecordPeriod(date_ini, date_end, sport)
self.windowmain.actualize_weekview(record_list, date_ini, date_end)
elif view=="month":
logging.debug('month view')
Modified: pytrainer/trunk/pytrainer/record.py
===================================================================
--- pytrainer/trunk/pytrainer/record.py 2009-11-23 22:09:52 UTC (rev 402)
+++ pytrainer/trunk/pytrainer/record.py 2009-11-25 09:45:20 UTC (rev 403)
@@ -253,14 +253,18 @@
"sports.name,date,distance,time,beats,comments,average,calories,id_record,maxspeed,maxbeats",
"date=\"%s\" and records.sport=sports.id_sports" %date)
- def getrecordPeriod(self,date_ini, date_end):
+ def getrecordPeriod(self,date_ini, date_end, sport=None):
+ #This is essentially the same as getrecordPeriodSport (except date ranges) - need to look at merging the two
tables = "records,sports"
- condition = "date>=\"%s\" and date<=\"%s\" and records.sport=sports.id_sports" %(date_ini,date_end)
+ if not sport:
+ condition = "date>=\"%s\" and date<=\"%s\" and records.sport=sports.id_sports" %(date_ini,date_end)
+ else:
+ condition = "date>=\"%s\" and date<=\"%s\" and records.sport=sports.id_sports and sports.name=\"%s\"" %(date_ini,date_end, sport)
return self.ddbb.select(tables,"date,distance,time,beats,comments,average,calories,maxspeed,maxbeats, sports.name", condition)
def getrecordPeriodSport(self,date_ini, date_end,sport):
- if sport<1 :
+ if not sport:
tables = "records"
condition = "date>\"%s\" and date<\"%s\"" %(date_ini,date_end)
else :
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-25 10:43:59
|
Revision: 404
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=404&view=rev
Author: jblance
Date: 2009-11-25 10:43:46 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Update week view to allow selection of distance, time, beats, average speed or calories
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/weekgraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-11-25 09:45:20 UTC (rev 403)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-11-25 10:43:46 UTC (rev 404)
@@ -145,6 +145,7 @@
inds = xrange(0, numCols)
xvals = [x+(1-width)/2 for x in xrange(0, numCols)]
cellText = []
+ self.showGraph=False
for key in keys:
for ind in inds:
ybottoms[ind] += yheights[ind]
@@ -154,11 +155,16 @@
index = xbars.index(xvalue)
if xvalue in yvalues[key]:
height = yvalues[key][xvalue]
+ if float(height) > 0.0:
+ self.showGraph=True
else:
height = self.NEARLY_ZERO
yheights[index] = height
cellText.append([self.fmt(x) for x in yheights])
- axis.bar(xvals, yheights, bottom=ybottoms, width=width, color=color, align='edge', label=key)
+ if self.showGraph:
+ axis.bar(xvals, yheights, bottom=ybottoms, width=width, color=color, align='edge', label=key)
+ else: #Only zero results
+ pass
axis.set_xticklabels('' * len(xbars))
axis.set_ylabel(ylabel)
plt.title(title)
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-25 09:45:20 UTC (rev 403)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-25 10:43:46 UTC (rev 404)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#403"
+ self.version ="1.6.0.9_svn#404"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
Modified: pytrainer/trunk/pytrainer/weekgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/weekgraph.py 2009-11-25 09:45:20 UTC (rev 403)
+++ pytrainer/trunk/pytrainer/weekgraph.py 2009-11-25 10:43:46 UTC (rev 404)
@@ -32,7 +32,13 @@
if value_selected < 0:
self.combovalue.set_active(0)
value_selected = 0
+ value_selected2 = self.combovalue2.get_active()
+ if value_selected2 < 0:
+ self.combovalue2.set_active(0)
+ value_selected2 = 0
logging.debug(str(values))
+ ylabel,title = self.get_value_params(value_selected)
+ xlabel = ""
#build days list to ensure localised values are used.
days = []
for day in range(0, 7):
@@ -40,29 +46,69 @@
incrementDay = datetime.timedelta(days=day)
dateToUse = dateTemp + incrementDay
days.append( dateToUse.strftime("%a") )
- valueDict = {}
- #TODO Need to add time etc (currently distance only)
+ valueDict = {} #Stores the totals
+ valueCount = {} #Counts the totals to allow for averaging if needed
+
for record in values:
day = datetime.datetime.strptime(record[0], "%Y-%m-%d").strftime("%a") # Gives Sun, Mon etc for this record
sport = record[9]
- distance = record[1]
+ value = self.getValue(record, value_selected)
if sport in valueDict: #Already got this sport
if day in valueDict[sport]: #Already got this sport on this day
- valueDict[sport][day] += distance
+ valueDict[sport][day] += value
+ valueCount[sport][day] += 1
else: #New day for this sport
- valueDict[sport][day] = distance
+ valueDict[sport][day] = value
+ valueCount[sport][day] = 1
else: #New sport
- valueDict[sport] = {day: distance}
+ valueDict[sport] = {day: value}
+ valueCount[sport] = {day: 1}
- xlabel = _("Day")
- ylabel = _("kilometers")
- title = _("Week View")
+ if value_selected == 2 or value_selected == 3:
+ for sport in valueDict.keys():
+ for day in valueDict[sport].keys():
+ logging.debug("averaging values: before %s (count %s)" % (valueDict[sport][day],valueCount[sport][day]))
+ if valueCount[sport][day] > 1: #Only average if 2 or more entries on this day
+ valueDict[sport][day] /= valueCount[sport][day]
+ logging.debug("averaging values: after %s" % valueDict[sport][day])
+
self.drawarea.drawStackedBars(days,valueDict,xlabel,ylabel,title)
logging.debug("<<")
+ def get_value_params(self,value):
+ if value == 0:
+ return _("Kilometers"),_("Weekly kilometers")
+ elif value == 1:
+ return _("Time in Hours"), _("Weekly Time")
+ elif value == 2:
+ return _("Beats per Minute"), _("weekly Beats")
+ elif value == 3:
+ return _("Average Speed (km/h)"), _("Weekly Speed Averages")
+ elif value == 4:
+ return _("Calories"), _("Weekly Calories")
+ def getValue(self,record,value_selected):
+ #hacemos una relacion entre el value_selected y los values / we make a relation between value_selected and the values
+ conv = {
+ 0: 1, #value 0 es kilometros (1)
+ 1: 2, #value 1 es tiempo (2)
+ 2: 3, #value 2 es pulsaciones(3)
+ 3: 5, #value 3 es media(5)
+ 4: 6 #value 4 es calorias(6)
+ }
+ value_sel = conv[value_selected]
+ #si la opcion es tiempo lo pasamos a horas / if the option is time we passed it to hours
+ if (value_sel == 2):
+ return self.getFloatValue(record[value_sel])/3600
+ else:
+ return self.getFloatValue(record[value_sel])
+
+ def getFloatValue(self, value):
+ try:
+ return float(value)
+ except:
+ return float(0)
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-26 05:30:18
|
Revision: 405
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=405&view=rev
Author: jblance
Date: 2009-11-26 05:30:09 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
Fix for week view labels to dosplay correctly with non-ascii characters
Modified Paths:
--------------
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/weekgraph.py
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-25 10:43:46 UTC (rev 404)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-26 05:30:09 UTC (rev 405)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#404"
+ self.version ="1.6.0.9_svn#405"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
Modified: pytrainer/trunk/pytrainer/weekgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/weekgraph.py 2009-11-25 10:43:46 UTC (rev 404)
+++ pytrainer/trunk/pytrainer/weekgraph.py 2009-11-26 05:30:09 UTC (rev 405)
@@ -45,7 +45,7 @@
dateTemp = datetime.datetime.strptime(date_ini, "%Y-%m-%d")
incrementDay = datetime.timedelta(days=day)
dateToUse = dateTemp + incrementDay
- days.append( dateToUse.strftime("%a") )
+ days.append( unicode(dateToUse.strftime("%a")) )
valueDict = {} #Stores the totals
valueCount = {} #Counts the totals to allow for averaging if needed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-26 05:40:16
|
Revision: 406
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=406&view=rev
Author: jblance
Date: 2009-11-26 05:40:08 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
Fix to pad minutes and second in time to 2 digits in day, week, month and year view
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-26 05:30:09 UTC (rev 405)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-26 05:40:08 UTC (rev 406)
@@ -310,8 +310,8 @@
self.day_distance.set_text("%0.2f" %distance)
hour,min,sec=self.parent.date.second2time(timeinseconds)
self.day_hour.set_text("%d" %hour)
- self.day_minute.set_text("%d" %min)
- self.day_second.set_text("%d" %sec)
+ self.day_minute.set_text("%02d" %min)
+ self.day_second.set_text("%02d" %sec)
self.day_beats.set_text("%0.2f" %tbeats)
self.day_maxbeats.set_text("%0.2f" %maxbeats)
self.day_average.set_text("%0.2f" %average)
@@ -405,8 +405,8 @@
self.weeka_distance.set_text("%0.2f" %km)
hour,min,sec = self.parent.date.second2time(time)
self.weeka_hour.set_text("%d" %hour)
- self.weeka_minute.set_text("%d" %min)
- self.weeka_second.set_text("%d" %sec)
+ self.weeka_minute.set_text("%02d" %min)
+ self.weeka_second.set_text("%02d" %sec)
self.weeka_maxbeats.set_text("%0.2f" %(maxbeats))
self.weeka_beats.set_text("%0.2f" %(tbeats))
self.weeka_average.set_text("%0.2f" %average)
@@ -483,8 +483,8 @@
self.montha_distance.set_text("%0.2f" %km)
hour,min,sec = self.parent.date.second2time(time)
self.montha_hour.set_text("%d" %hour)
- self.montha_minute.set_text("%d" %min)
- self.montha_second.set_text("%d" %sec)
+ self.montha_minute.set_text("%02d" %min)
+ self.montha_second.set_text("%02d" %sec)
self.montha_maxbeats.set_text("%0.2f" %(maxbeats))
self.montha_beats.set_text("%0.2f" %(tbeats))
self.montha_average.set_text("%0.2f" %average)
@@ -543,8 +543,8 @@
self.yeara_distance.set_text("%0.2f" %km)
hour,min,sec = self.parent.date.second2time(time)
self.yeara_hour.set_text("%d" %hour)
- self.yeara_minute.set_text("%d" %min)
- self.yeara_second.set_text("%d" %sec)
+ self.yeara_minute.set_text("%02d" %min)
+ self.yeara_second.set_text("%02d" %sec)
self.yeara_beats.set_text("%0.2f" %tbeats)
self.yeara_maxbeats.set_text("%0.2f" %(maxbeats))
self.yeara_average.set_text("%0.2f" %average)
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-26 05:30:09 UTC (rev 405)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-26 05:40:08 UTC (rev 406)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#405"
+ self.version ="1.6.0.9_svn#406"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-26 07:51:44
|
Revision: 407
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=407&view=rev
Author: jblance
Date: 2009-11-26 07:51:34 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
Fix for month and year graphs to correctly display 0 height columns. Year graph now displays text version of month
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/lib/date.py
pytrainer/trunk/pytrainer/main.py
pytrainer/trunk/pytrainer/monthgraph.py
pytrainer/trunk/pytrainer/weekgraph.py
pytrainer/trunk/pytrainer/yeargraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -57,52 +57,70 @@
logging.debug('>>')
self.removeVboxChildren()
figure = Figure(figsize=(6,4), dpi=72)
- #canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
-
+ numCols=len(xvalues[0])
xmod = 0.4
- if len(xvalues) > 1:
- width = 0.40
- else:
- width = 0.80
- i=0
-
- for value in xvalues:
- if i<1:
- axis = figure.add_subplot(111)
- axis.set_xlim(-width,len(xvalues[i]))
- axis.set_xlabel(xlabel[i])
- axis.set_ylabel(ylabel[i])
- axis.set_title(title[i])
- j=0
- #print "xvalues: %s" % (xvalues)
- #print "yvalues: %s" % (yvalues)
- for x in xvalues[i]:
- xvalues[i][j]=x-xmod
- j+=1
- axis.bar(xvalues[i], yvalues[i], width, color=color[i])
-
- axis.grid(True)
- for tl in axis.get_yticklabels():
- tl.set_color('%s' %color[i])
- if i>=1:
- ax2 = axis.twinx()
- ax2.bar(xvalues[i], yvalues[i], width, color=color[i])
- for tl in ax2.get_yticklabels():
- tl.set_color('%s' %color[i])
- axis.set_xlabel(xlabel[i])
- i+=1
-
- if (len(xvalues)>1):
+ self.showGraph=False
+ axis = figure.add_subplot(111)
+
+ if len(xvalues) == 1: #One axis
+ barWidth = 0.8
+ barOffset = 0.1
+ elif len(xvalues) == 2: #Twin axes
+ barWidth = 0.4
+ barOffset = 0.1
+ else: #Error
+ return
+
+ axis.set_xlabel(xlabel[0])
+ axis.set_ylabel(ylabel[0])
+ xvals = [x+barOffset for x in range(0, numCols)]
+ yvals = [0] * numCols
+ for i in range(0, numCols):
+ yval = yvalues[0][i]
+ if float(yval) > 0.0:
+ self.showGraph=True
+ else:
+ yval = self.NEARLY_ZERO
+ yvals[i] = yval
+ if self.showGraph:
+ axis.bar(xvals, yvals, barWidth, color=color[0], align='edge')
+ else: #Only zero results
+ pass
+
+ axis.grid(True)
+ axis.set_title("%s" %(ylabel[0]))
+ for tl in axis.get_yticklabels():
+ tl.set_color('%s' %color[0])
+
+ if len(xvalues) == 2: #Display twin axis
+ ax2 = axis.twinx()
+ xvals = [x+barOffset+barWidth for x in range(0, numCols)]
+ for i in range(0, numCols):
+ yval = yvalues[1][i]
+ if float(yval) > 0.0:
+ self.showGraph=True
+ else:
+ yval = self.NEARLY_ZERO
+ yvals[i] = yval
+ if self.showGraph:
+ ax2.bar(xvals, yvals, barWidth, color=color[1], align='edge')
+ ax2.set_ylabel(ylabel[1])
+ else: #Only zero results
+ pass
+ for tl in ax2.get_yticklabels():
+ tl.set_color('%s' %color[1])
axis.set_title("%s vs %s" %(ylabel[0],ylabel[1]))
- else:
- axis.set_title("%s" %(ylabel[0]))
+ tickLocations = [x+0.5 for x in xrange(0, numCols)]
+ axis.set_xticks(tickLocations)
+ axis.set_xticklabels(xvalues[0])
+ axis.set_xlim(0, numCols)
canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
canvas.show()
self.vbox.pack_start(canvas, True, True)
- toolbar = NavigationToolbar(canvas, self.window)
- self.vbox.pack_start(toolbar, False, False)
+ #toolbar = NavigationToolbar(canvas, self.window)
+ #self.vbox.pack_start(toolbar, False, False)
for child in self.vbox.get_children():
logging.debug('Child available: '+str(child))
@@ -115,13 +133,22 @@
x = x % len(colors)
return colors[x]
- def fmt(self, x):
+ def fmtTableText(self, x, valuesAreTime):
if x <= 0.0001:
return ' '
+ elif valuesAreTime:
+ hour = int(x)
+ minutes = int((x-hour)*60)
+ hourLabel = _("h")
+ minLabel = _("min")
+ if hour > 0:
+ return "%d%s %02d%s" % (hour, hourLabel, minutes, minLabel)
+ else:
+ return "%02d%s" % (minutes, minLabel)
else:
return '%1.1f' % x
- def drawStackedBars(self,xbars,yvalues,xlabel,ylabel,title):
+ def drawStackedBars(self,xbars,yvalues,ylabel,title, valuesAreTime=False):
'''function to draw stacked bars
xbars needs to be a list of strings, e.g. ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
yvalues needs to be a dict e.g. {'Kayak': {'Tue': 10.08, 'Fri': 17.579999999999998, 'Thu': 15.66, 'Sat': 30.619999999999997}, {'Run': {'Mon': 9.65, 'Sun': 15.59}}
@@ -160,7 +187,7 @@
else:
height = self.NEARLY_ZERO
yheights[index] = height
- cellText.append([self.fmt(x) for x in yheights])
+ cellText.append([self.fmtTableText(x, valuesAreTime) for x in yheights])
if self.showGraph:
axis.bar(xvals, yheights, bottom=ybottoms, width=width, color=color, align='edge', label=key)
else: #Only zero results
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -205,8 +205,8 @@
self.record_date.set_text(str(date))
hour,min,sec=self.parent.date.second2time(int(record_list[3]))
self.record_hour.set_text("%d" %hour)
- self.record_minute.set_text("%d" %min)
- self.record_second.set_text("%d" %sec)
+ self.record_minute.set_text("%02d" %min)
+ self.record_second.set_text("%02d" %sec)
self.record_calories.set_text("%0.0f" %calories)
self.record_title.set_text(title)
buffer = self.record_comments.get_buffer()
@@ -497,9 +497,9 @@
self.monthview.set_sensitive(0)
logging.debug("<<")
- def actualize_monthgraph(self,record_list):
+ def actualize_monthgraph(self,record_list, daysInMonth):
logging.debug(">>")
- self.drawareamonth.drawgraph(record_list)
+ self.drawareamonth.drawgraph(record_list, daysInMonth)
logging.debug("<<")
def actualize_yearview(self,record_list, year):
Modified: pytrainer/trunk/pytrainer/lib/date.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/date.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/lib/date.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -93,22 +93,24 @@
return date_ini, date_end
def getNameMonth(self, date):
- month_name = {
- "01":_("January"),
- "02":_("Febrary"),
- "03":_("March"),
- "04":_("April"),
- "05":_("May"),
- "06":_("June"),
- "07":_("July"),
- "08":_("August"),
- "09":_("September"),
- "10":_("October"),
- "11":_("November"),
- "12":_("December")
- }
+ #month_name = {
+ # "01":_("January"),
+ # "02":_("Febrary"),
+ # "03":_("March"),
+ # "04":_("April"),
+ # "05":_("May"),
+ # "06":_("June"),
+ # "07":_("July"),
+ # "08":_("August"),
+ # "09":_("September"),
+ # "10":_("October"),
+ # "11":_("November"),
+ # "12":_("December")
+ # }
year,month,day = date.split("-")
- return month_name["%s" %month]
+ day, daysInMonth = calendar.monthrange(int(year), int(month))
+ monthName = calendar.month_name[int(month)]
+ return monthName, daysInMonth
def getYear(self,date):
year,month,day = date.split("-")
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#406"
+ self.version ="1.6.0.9_svn#407"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
@@ -243,9 +243,9 @@
sport = self.windowmain.getSportSelected()
record_list = self.record.getrecordPeriodSport(date_ini, date_end,sport)
#logging.debug('record list: '+record_list)
- nameMonth = self.date.getNameMonth(date_selected)
+ nameMonth, daysInMonth = self.date.getNameMonth(date_selected)
self.windowmain.actualize_monthview(record_list, nameMonth)
- self.windowmain.actualize_monthgraph(record_list)
+ self.windowmain.actualize_monthgraph(record_list, daysInMonth)
elif view=="year":
logging.debug('year view')
date_ini, date_end = self.date.getYearInterval(date_selected)
Modified: pytrainer/trunk/pytrainer/monthgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/monthgraph.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/monthgraph.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -24,7 +24,7 @@
self.combovalue = combovalue
self.combovalue2 = combovalue2
- def drawgraph(self,values):
+ def drawgraph(self,values, daysInMonth):
xval = []
yval = []
xlab = []
@@ -36,9 +36,8 @@
if value_selected < 0:
self.combovalue.set_active(0)
value_selected = 0
- daysmonth,xlabel,ylabel,title,color = self.get_value_params(value_selected)
- #print "daysmonth %s,xlabel %s,ylabel %s,title %s,color %s" % (daysmonth,xlabel,ylabel,title,color)
- xvalues,yvalues = self.get_values(values,value_selected,daysmonth)
+ xlabel,ylabel,title,color = self.get_value_params(value_selected)
+ xvalues,yvalues = self.get_values(values,value_selected,daysInMonth)
xval.append(xvalues)
yval.append(yvalues)
@@ -55,8 +54,8 @@
value_selected2 = 0
if value_selected2 > 0:
value_selected2 = value_selected2-1
- daysmonth,xlabel,ylabel,title,color = self.get_value_params(value_selected2)
- xvalues,yvalues = self.get_values(values,value_selected2,daysmonth)
+ xlabel,ylabel,title,color = self.get_value_params(value_selected2)
+ xvalues,yvalues = self.get_values(values,value_selected2,daysInMonth)
xval.append(xvalues)
yval.append(yvalues)
xlab.append(xlabel)
@@ -67,17 +66,17 @@
def get_value_params(self,value):
if value == 0:
- return 32,_("day"),_("Kilometers"),_("Daily kilometers"),"y"
+ return _("day"),_("Kilometers"),_("Daily kilometers"),"y"
elif value == 1:
- return 32,_("day"),_("Time in Hours"), _("Daily Time"),"b"
+ return _("day"),_("Time in Hours"), _("Daily Time"),"b"
elif value == 2:
- return 32,_("day"),_("Beats per Minute"), _("Daily Beats"),"r"
+ return _("day"),_("Beats per Minute"), _("Daily Beats"),"r"
elif value == 3:
- return 32,_("day"),_("Average (km/h)"), _("Daily Averages"),"g"
+ return _("day"),_("Average (km/h)"), _("Daily Averages"),"g"
elif value == 4:
- return 32,_("day"),_("Calories"), _("Daily Calories"),"b"
+ return _("day"),_("Calories"), _("Daily Calories"),"b"
- def get_values(self,values,value_selected,daysmonth):
+ def get_values(self,values,value_selected,daysInMonth):
#hacemos una relacion entre el value_selected y los values / we make a relation between value_selected and the values
conv = {
0: 1, #value 0 es kilometros (1)
@@ -88,7 +87,7 @@
}
list_values = {}
list_average = {}
- for i in range(1,32):
+ for i in range(1,daysInMonth+1):
list_values[i]=0
list_average[i]=0
@@ -113,8 +112,8 @@
xunits = []
yunits = []
- for i in range (0,daysmonth):
- xunits.append(i)
+ for i in range (1,daysInMonth+1):
+ xunits.append(i)
yunits.append(float(0))
for value in list_values:
Modified: pytrainer/trunk/pytrainer/weekgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/weekgraph.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/weekgraph.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -19,6 +19,7 @@
from gui.drawArea import DrawArea
import logging
import datetime
+import calendar
class WeekGraph:
def __init__(self, vbox = None, window = None, combovalue = None, combovalue2 = None):
@@ -38,8 +39,8 @@
value_selected2 = 0
logging.debug(str(values))
ylabel,title = self.get_value_params(value_selected)
- xlabel = ""
#build days list to ensure localised values are used.
+ #TODO look at using calendar.day_abbr for this
days = []
for day in range(0, 7):
dateTemp = datetime.datetime.strptime(date_ini, "%Y-%m-%d")
@@ -72,8 +73,12 @@
if valueCount[sport][day] > 1: #Only average if 2 or more entries on this day
valueDict[sport][day] /= valueCount[sport][day]
logging.debug("averaging values: after %s" % valueDict[sport][day])
+ if value_selected == 1: #Values are of time type
+ valuesAreTime=True
+ else:
+ valuesAreTime=False
- self.drawarea.drawStackedBars(days,valueDict,xlabel,ylabel,title)
+ self.drawarea.drawStackedBars(days,valueDict,ylabel,title, valuesAreTime)
logging.debug("<<")
def get_value_params(self,value):
Modified: pytrainer/trunk/pytrainer/yeargraph.py
===================================================================
--- pytrainer/trunk/pytrainer/yeargraph.py 2009-11-26 05:40:08 UTC (rev 406)
+++ pytrainer/trunk/pytrainer/yeargraph.py 2009-11-26 07:51:34 UTC (rev 407)
@@ -17,6 +17,7 @@
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from gui.drawArea import DrawArea
+import calendar
class YearGraph:
def __init__(self, vbox = None, window = None, combovalue = None, combovalue2 = None):
@@ -129,7 +130,8 @@
xunits = []
yunits = []
for i in range (0,monthsnumber):
- xunits.append(i)
+ xunits.append(unicode(calendar.month_abbr[i+1]))
+ #xunits.append(i)
yunits.append(float(0))
for i in list_values:
if list_average[i] > 0:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-29 00:20:26
|
Revision: 409
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=409&view=rev
Author: jblance
Date: 2009-11-29 00:19:32 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Modified on_sportlist_changed event to improve performance
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-26 09:48:08 UTC (rev 408)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-11-29 00:19:32 UTC (rev 409)
@@ -46,6 +46,7 @@
self.popup = PopupMenu(data_path,self)
self.block = False
+ self.activeSport = None
def new(self):
self.menublocking = 0
@@ -122,15 +123,19 @@
def createMap(self,Googlemaps,waypoint):
self.googlemaps = Googlemaps(self.data_path, self.map_vbox,waypoint)
- def updateSportList(self,listSport):
+ def updateSportList(self,listSport):
logging.debug(">>")
- self.sportlist.set_active(1)
- while (self.sportlist.get_active() == 1):
- self.sportlist.remove_text(1)
- self.sportlist.set_active(1)
+ liststore = self.sportlist.get_model()
+ if self.sportlist.get_active() is not 0:
+ self.sportlist.set_active(0) #Set first item active if it isnt
+ firstEntry = self.sportlist.get_active_text()
+ liststore.clear() #Delete all items
+ #Re-add "All Sports"
+ liststore.append([firstEntry])
+ #Re-add all sports in listSport
for i in listSport:
- self.sportlist.append_text(i[0])
- self.sportlist.set_active(0)
+ liststore.append([i[0]])
+ self.sportlist.set_active(0)
logging.debug("<<")
def create_treeview(self,treeview,column_names):
@@ -769,7 +774,11 @@
def on_sportlist_changed(self,widget):
logging.debug("--")
- self.parent.refreshGraphView(self.selected_view)
+ if self.sportlist.get_active() != self.activeSport:
+ self.activeSport = self.sportlist.get_active()
+ self.parent.refreshGraphView(self.selected_view)
+ else:
+ logging.debug("on_sportlist_changed called with no change")
def on_page_change(self,widget,gpointer,page):
logging.debug("--")
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-26 09:48:08 UTC (rev 408)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-29 00:19:32 UTC (rev 409)
@@ -93,7 +93,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#408"
+ self.version ="1.6.0.9_svn#409"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-30 06:24:45
|
Revision: 412
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=412&view=rev
Author: jblance
Date: 2009-11-30 06:24:35 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Migrate gpx.py to lxml
Modified Paths:
--------------
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-29 09:52:42 UTC (rev 411)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 06:24:35 UTC (rev 412)
@@ -26,21 +26,23 @@
import time
import logging
from xmlUtils import XMLParser
-import xml.dom
-from xml.dom import minidom, Node, getDOMImplementation
-import xml.etree.cElementTree
-from gtrnctr2gpx import gtrnctr2gpx # copied to pytrainer/lib/ directory
+#import xml.dom
+#from xml.dom import minidom, Node, getDOMImplementation
+#import xml.etree.cElementTree
+from lxml import etree
+#from gtrnctr2gpx import gtrnctr2gpx # copied to pytrainer/lib/ directory
# use of namespaces is mandatory if defined
-mainNS = string.Template("{http://www.topografix.com/GPX/1/1}$tag")
+mainNS = string.Template(".//{http://www.topografix.com/GPX/1/1}$tag")
timeTag = mainNS.substitute(tag="time")
trackTag = mainNS.substitute(tag="trk")
trackPointTag = mainNS.substitute(tag="trkpt")
+elevationTag = mainNS.substitute(tag="ele")
+nameTag = mainNS.substitute(tag="name")
-mainNSGpX = string.Template("{http://www.topografix.com/GPX/1/1}$tag")
-trackTag = mainNSGpX.substitute(tag="trk")
-trackPointTag = mainNSGpX.substitute(tag="trkpt")
-timeTag = mainNSGpX.substitute(tag="time")
+gpxdataNS = string.Template(".//{http://www.cluetrust.com/XML/GPXDATA/1/0}$tag")
+calorieTag = gpxdataNS.substitute(tag="calories")
+hrTag = gpxdataNS.substitute(tag="hr")
class Gpx:
def __init__(self, data_path = None, filename = None, trkname = None):
@@ -62,7 +64,7 @@
if not os.path.isfile(self.filename):
return None
logging.debug("parsing content from "+self.filename)
- self.dom = xml.dom.minidom.parse(self.filename)
+ self.tree = etree.ElementTree(file=filename).getroot()
logging.debug("getting values...")
self.Values = self._getValues()
logging.debug("<<")
@@ -74,16 +76,18 @@
return self.date
def getTrackRoutes(self):
- trks = self.dom.getElementsByTagName("trk")
+ trks = tree.findall(trackTag)
tracks = []
retorno = []
for trk in trks:
- if len(trk.getElementsByTagName("name")) > 0:
- name = trk.getElementsByTagName("name")[0].firstChild.data
+ nameResult = trk.find(nameTag)
+ if nameResult is not None:
+ name = nameResult.text
else:
name = _("No Name")
- if len(trk.getElementsByTagName("time")) > 0:
- time_ = trk.getElementsByTagName("time")[0].firstChild.data # check timezone
+ timeResult = trk.find(timeTag)
+ if timeResult is not None:
+ time_ = timeResult.text # check timezone
mk_time = time.strptime(time_, "%Y-%m-%dT%H:%M:%SZ")
time_ = time.strftime("%Y-%m-%d", mk_time)
else:
@@ -103,17 +107,21 @@
def getCalories(self):
return self.calories
-
- def _getValues(self): # migrate to cElementTree
+
+ def _getValues(self):
+ '''
+ Migrated to eTree XML processing 26 Nov 2009 - jblance
+ '''
+
logging.debug(">>")
- dom = self.dom
+ tree = self.tree
- trkpoints = dom.getElementsByTagName("trkpt")
+ trkpoints = tree.findall(trackPointTag)
#start with the info at trkseg level
#calories - maybe more than one, currently adding them together
- calorieCollection = dom.getElementsByTagName("gpxdata:calories")
+ calorieCollection = tree.findall(calorieTag)
for cal in calorieCollection:
- self.calories += int(cal.firstChild.data)
+ self.calories += int(cal.text)
retorno = []
his_vel = []
last_lat = "False"
@@ -127,37 +135,39 @@
if not len(trkpoints):
return retorno
- date_ = trkpoints[0].getElementsByTagName("time")[0].firstChild.data
+ date_ = tree.find(timeTag).text
mk_time = time.strptime(date_, "%Y-%m-%dT%H:%M:%SZ")
self.date = time.strftime("%Y-%m-%d", mk_time)
for trkpoint in trkpoints:
- lat = trkpoint.attributes["lat"].value
- lon = trkpoint.attributes["lon"].value
+ lat = trkpoint.get("lat")
+ lon = trkpoint.get("lon")
#get the heart rate value from the gpx extended format file
- if len(trkpoint.getElementsByTagName("gpxdata:hr")) > 0:
- hr = int(trkpoint.getElementsByTagName("gpxdata:hr")[0].firstChild.data)
+ hrResult = trkpoint.find(hrTag)
+ if hrResult is not None:
+ hr = int(hrResult.text)
len_validhrpoints += 1
else:
hr = 0
- if len(trkpoint.getElementsByTagName("time")) > 0:
- time_ = trkpoint.getElementsByTagName("time")[0].firstChild.data
+ timeResult = trkpoint.find(timeTag)
+ if timeResult is not None:
+ time_ = timeResult.text
mk_time = time.strptime(time_, "%Y-%m-%dT%H:%M:%SZ")
time_ = time.mktime(mk_time)
else:
time_ = 1
- ele = trkpoint.getElementsByTagName("ele")[0].firstChild.data
- #chequeamos que la altura sea correcta
+ ele = trkpoint.find(elevationTag).text
+ #chequeamos que la altura sea correcta / check that the height is correct
if len(ele)<15:
tmp_alt = int(float(ele))
- #evitamos los puntos blancos
+ #evitamos los puntos blancos / we avoid the white points
if (float(lat) < -0.000001) or (float(lat) > 0.0000001):
tmp_lat = float(lat)*0.01745329252
tmp_lon = float(lon)*0.01745329252
tmp_time = int(time_)
- #Para las vueltas diferentes a la primera
+ #Para las vueltas diferentes a la primera / For the returns different from first
if last_lat != "False":
time_ = tmp_time - last_time
if time_>0:
@@ -175,16 +185,16 @@
total_hr += hr
if hr>self.maxhr:
self.maxhr = hr
- #dividimos kilometros por hora (no por segundo)
+ #dividimos kilometros por hora (no por segundo) / Calculate kilometers per hour (not including seconds)
tmp_vel = dist/((time_)/3600.0)
- vel,his_vel = self._calculate_velocity(tmp_vel,his_vel)
- #si la velocidad es menor de 90 lo damos por bueno
+ vel,his_vel = self._calculate_velocity(tmp_vel,his_vel, 3)
+ #si la velocidad es menor de 90 lo damos por bueno / if speed is greater than 90 or time greater than 100 we exclude the result
if vel<90 and time_ <100:
if vel>self.maxvel:
self.maxvel=vel
self.total_time += time_
- retorno.append((total_dist,tmp_alt, self.total_time,vel,lat,lon,hr))
- rel_alt = tmp_alt - last_alt
+ retorno.append((total_dist,tmp_alt, self.total_time,vel,lat,lon,hr)) #Could add rpm here
+ rel_alt = tmp_alt - last_alt #Could allow for some 'jitter' in height here
if rel_alt > 0:
self.upositive += rel_alt
elif rel_alt < 0:
@@ -202,47 +212,39 @@
logging.debug("<<")
return retorno
- def _calculate_velocity(self,velocity, arr_velocity):
- #logging.debug(">>")
+ def _calculate_velocity(self,velocity, arr_velocity, numToAverage): #TODO Check & make generic
+ '''Function to calculate moving average for speed'''
arr_velocity.append(velocity)
- if len(arr_velocity)>3:
+ if len(arr_velocity)>numToAverage:
arr_velocity.pop(0)
- if len(arr_velocity)<3:
- vel=0
- else:
- vel = (arr_velocity[0]+arr_velocity[1]+arr_velocity[2])/3
- #logging.debug("<<")
+ if len(arr_velocity)<numToAverage:
+ #Got too few numbers to average
+ #Pad with duplicates
+ for x in range(len(arr_velocity), numToAverage):
+ arr_velocity.append(velocity)
+ vel = 0
+ for v in arr_velocity:
+ vel+= v
+ vel /= numToAverage
return vel,arr_velocity
- """
- def getStartTimeFromGPX(self, gpxFile):
- 25.03.2008 - dgranda
- Retrieves start time from a given gpx file
- args:
- - gpxFile: path to xml file (gpx format)
- returns: string with start time - 2008-03-22T12:17:43Z
- logging.debug("--")
- xmldoc = xml.dom.minidom.parse(gpxFile)
- times = xmldoc.getElementsByTagName("time")
- return times[0].firstChild.data
- """
def getStartTimeFromGPX(self, gpxFile):
"""03.05.2008 - dgranda
- Retrieves start time from a given gpx file (cElementTree version)
+ Retrieves start time from a given gpx file
args:
- gpxFile: path to xml file (gpx format)
returns: string with start time - 2008-03-22T12:17:43Z"""
logging.debug(">>")
- try:
- tree = xml.etree.cElementTree.parse(gpxFile)
- date_time = tree.getroot().findtext(".//"+timeTag) #returns first instance found
- logging.debug(gpxFile+" | "+ date_time)
- except Exception:
+ date_time = tree.find(timeTag) #returns first instance found
+ logging.debug(gpxFile+" | "+ date_time)
+ if date_time is None:
print "Problems when retrieving start time from "+gpxFile+". Please check data integrity"
date_time=0
logging.debug("<<")
return date_time
+ #TODO Pending removal
+ '''
def retrieveDataFromGTRNCTR(self, gtrnctrFile, entry):
"""23.03.2008 - dgranda
Builds a new GPX file based on one entry from GPS (dates matching)
@@ -256,4 +258,4 @@
newGPXEntry = self.conf.tmpdir + "/new_entry.gpx"
gtrnctr2gpx(selectedEntry, newGPXEntry)
logging.debug('<<')
- return newGPXEntry
+ return newGPXEntry '''
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-29 09:52:42 UTC (rev 411)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-30 06:24:35 UTC (rev 412)
@@ -98,7 +98,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#411"
+ self.version ="1.6.0.9_svn#412"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-30 06:53:37
|
Revision: 413
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=413&view=rev
Author: jblance
Date: 2009-11-30 06:53:27 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Fix error in gpx.py
Modified Paths:
--------------
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 06:24:35 UTC (rev 412)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 06:53:27 UTC (rev 413)
@@ -76,7 +76,7 @@
return self.date
def getTrackRoutes(self):
- trks = tree.findall(trackTag)
+ trks = self.tree.findall(trackTag)
tracks = []
retorno = []
for trk in trks:
@@ -235,7 +235,7 @@
- gpxFile: path to xml file (gpx format)
returns: string with start time - 2008-03-22T12:17:43Z"""
logging.debug(">>")
- date_time = tree.find(timeTag) #returns first instance found
+ date_time = self.tree.find(timeTag) #returns first instance found
logging.debug(gpxFile+" | "+ date_time)
if date_time is None:
print "Problems when retrieving start time from "+gpxFile+". Please check data integrity"
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-30 06:24:35 UTC (rev 412)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-30 06:53:27 UTC (rev 413)
@@ -98,7 +98,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#412"
+ self.version ="1.6.0.9_svn#413"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-30 06:58:15
|
Revision: 414
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=414&view=rev
Author: jblance
Date: 2009-11-30 06:58:09 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Fix error in gpx.py
Modified Paths:
--------------
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 06:53:27 UTC (rev 413)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 06:58:09 UTC (rev 414)
@@ -236,12 +236,12 @@
returns: string with start time - 2008-03-22T12:17:43Z"""
logging.debug(">>")
date_time = self.tree.find(timeTag) #returns first instance found
- logging.debug(gpxFile+" | "+ date_time)
if date_time is None:
print "Problems when retrieving start time from "+gpxFile+". Please check data integrity"
- date_time=0
+ return 0
+ logging.debug(gpxFile+" | "+ date_time.text)
logging.debug("<<")
- return date_time
+ return date_time.text
#TODO Pending removal
'''
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-30 06:53:27 UTC (rev 413)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-30 06:58:09 UTC (rev 414)
@@ -98,7 +98,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#413"
+ self.version ="1.6.0.9_svn#414"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-11-30 10:02:55
|
Revision: 415
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=415&view=rev
Author: jblance
Date: 2009-11-30 10:02:45 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Added info windows to Google Maps version 3 api code
Modified Paths:
--------------
pytrainer/trunk/pytrainer/extensions/googlemaps.py
pytrainer/trunk/pytrainer/lib/date.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/extensions/googlemaps.py
===================================================================
--- pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-11-30 06:58:09 UTC (rev 414)
+++ pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-11-30 10:02:45 UTC (rev 415)
@@ -25,6 +25,7 @@
from pytrainer.lib.gpx import Gpx
import pytrainer.lib.points as Points
from pytrainer.lib.fileUtils import fileUtils
+from pytrainer.record import Record
class Googlemaps:
def __init__(self, data_path = None, vbox = None, waypoint = None, useGM3 = False):
@@ -38,6 +39,7 @@
self.htmlfile = "%s/index.html" % (self.conf.getValue("tmpdir"))
self.waypoint=waypoint
self.useGM3 = useGM3
+ self.record = Record()
logging.debug("<<")
def drawMap(self,id_record):
@@ -79,8 +81,13 @@
points = points.replace("\\","\\\\")
if self.useGM3:
logging.debug("Using Google Maps version 3 API")
- startinfo = "Start<br>TODO: Put ??? info here"
- finishinfo = "End<br>TODO: Put summary info here?"
+ #"sports.name,date,distance,time,beats,comments,average,calories,id_record,title,upositive,unegative,maxspeed,maxpace,pace,maxbeats"
+ info = self.record.getrecordInfo(id_record)
+ timeHours = int(info[0][3]) / 3600
+ timeMin = (float(info[0][3]) / 3600.0 - timeHours) * 60
+ time = "%d%s %02d%s" % (timeHours, _("h"), timeMin, _("min"))
+ startinfo = "<div id='info_content'>%s: %s</div>" % (info[0][0], info[0][9])
+ finishinfo = "<div id='info_content'>%s: %s<br>%s: %s%s</div>" % (_("Time"), time, _("Distance"), info[0][2], _("km"))
self.createHtml_api3(polyline, minlat, minlon, maxlat, maxlon, startinfo, finishinfo)
else:
logging.debug("Using Google Maps version 2 API")
Modified: pytrainer/trunk/pytrainer/lib/date.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/date.py 2009-11-30 06:58:09 UTC (rev 414)
+++ pytrainer/trunk/pytrainer/lib/date.py 2009-11-30 10:02:45 UTC (rev 415)
@@ -59,7 +59,7 @@
Problems as python date functions do not respect locale (i.e. Sunday is always start of week????)
Note: %w gives weekday as a decimal number [0(Sunday),6(Saturday)].
'''
- if prf_us_system == "True":
+ if prf_us_system:
#Sunday is first day of week
weekDate = datetime.datetime.strptime(date, "%Y-%m-%d")
dayOfWeek = int(weekDate.strftime("%w"))
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-30 06:58:09 UTC (rev 414)
+++ pytrainer/trunk/pytrainer/main.py 2009-11-30 10:02:45 UTC (rev 415)
@@ -50,7 +50,6 @@
#from gui.windowextensions import WindowExtensions
from gui.windowmain import Main
from gui.warning import Warning
-from lib.system import checkConf
from lib.date import Date
from lib.gpx import Gpx
from lib.soapUtils import webService
@@ -98,7 +97,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#414"
+ self.version ="1.6.0.9_svn#415"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
@@ -119,7 +118,10 @@
self.filename = self.conf.getValue("conffile")
logging.debug('retrieving data from '+ self.filename)
self.configuration = XMLParser(self.filename)
- self.prf_us_system = self.configuration.getValue("pytraining","prf_us_system")
+ if self.configuration.getValue("pytraining","prf_us_system") == "True":
+ self.prf_us_system = True
+ else:
+ self.prf_us_system = False
self.ddbb = DDBB(self.configuration)
logging.debug('connecting to DDBB')
self.ddbb.connect()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-12-01 09:41:34
|
Revision: 416
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=416&view=rev
Author: jblance
Date: 2009-12-01 09:41:27 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Some interim lap progress
Modified Paths:
--------------
pytrainer/trunk/pytrainer/extensions/googlemaps.py
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/extensions/googlemaps.py
===================================================================
--- pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-11-30 10:02:45 UTC (rev 415)
+++ pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-12-01 09:41:27 UTC (rev 416)
@@ -81,6 +81,7 @@
points = points.replace("\\","\\\\")
if self.useGM3:
logging.debug("Using Google Maps version 3 API")
+ laps = gpx.getLaps() # [](elapsedTime, lat, lon)
#"sports.name,date,distance,time,beats,comments,average,calories,id_record,title,upositive,unegative,maxspeed,maxpace,pace,maxbeats"
info = self.record.getrecordInfo(id_record)
timeHours = int(info[0][3]) / 3600
@@ -88,7 +89,7 @@
time = "%d%s %02d%s" % (timeHours, _("h"), timeMin, _("min"))
startinfo = "<div id='info_content'>%s: %s</div>" % (info[0][0], info[0][9])
finishinfo = "<div id='info_content'>%s: %s<br>%s: %s%s</div>" % (_("Time"), time, _("Distance"), info[0][2], _("km"))
- self.createHtml_api3(polyline, minlat, minlon, maxlat, maxlon, startinfo, finishinfo)
+ self.createHtml_api3(polyline, minlat, minlon, maxlat, maxlon, startinfo, finishinfo, laps)
else:
logging.debug("Using Google Maps version 2 API")
self.createHtml(points,levels,pointlist[0])
@@ -99,7 +100,7 @@
self.moz.load_url("file://%s" % (self.htmlfile))
logging.debug("<<")
- def createHtml_api3(self,polyline, minlat, minlon, maxlat, maxlon, startinfo, finishinfo):
+ def createHtml_api3(self,polyline, minlat, minlon, maxlat, maxlon, startinfo, finishinfo, laps):
'''
Generate a Google maps html file using the v3 api
documentation at http://code.google.com/apis/maps/documentation/v3
@@ -125,6 +126,7 @@
content += " var finishcontent = \"%s\";\n" % (finishinfo)
content += " var startimageloc = \"%s/glade/start.png\";\n" % (os.path.abspath(self.data_path))
content += " var finishimageloc = \"%s/glade/finish.png\";\n" % (os.path.abspath(self.data_path))
+ content += " var lapimageloc = \"%s/glade/waypoint.png\";\n" % (os.path.abspath(self.data_path))
content +='''
var myOptions = {
zoom: 8,
@@ -148,6 +150,14 @@
// The anchor for this image is the base of the flagpole
new google.maps.Point(16, 32));\n
+ var lapimage = new google.maps.MarkerImage(lapimageloc,\n
+ // This marker is 32 pixels wide by 32 pixels tall.
+ new google.maps.Size(32, 32),
+ // The origin for this image is 0,0.
+ new google.maps.Point(0,0),
+ // The anchor for this image is the base of the flagpole
+ new google.maps.Point(16, 32));\n
+
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var startmarker = new google.maps.Marker({
position: startlatlng,
@@ -176,8 +186,16 @@
google.maps.event.addListener(finishmarker, 'click', function() {
finishinfo.open(map,finishmarker);
- });
+ });\n'''
+ for lap in laps:
+ lapNumber = laps.index(lap)
+ content += "var lap%dmarker = new google.maps.Marker({position: new google.maps.LatLng(%f, %f), icon: lapimage, map: map, title:\"Lap%d\"}); \n " % (lapNumber, float(lap[1]), float(lap[2]), lapNumber)
+ content += "var lap%d = new google.maps.InfoWindow({content: \"End of lap:%s<br>Elapsed time:%s\" });\n" % (lapNumber, lapNumber+1, lap[0])
+ content += "google.maps.event.addListener(lap%dmarker, 'click', function() { lap%d.open(map,lap%dmarker); });\n" % (lapNumber,lapNumber,lapNumber)
+
+ content += '''
+
var boundsBox = new google.maps.LatLngBounds(swlatlng, nelatlng );\n
map.fitBounds(boundsBox);\n
var polylineCoordinates = [\n'''
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-11-30 10:02:45 UTC (rev 415)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-12-01 09:41:27 UTC (rev 416)
@@ -24,6 +24,7 @@
from system import checkConf
import time
+from datetime import datetime
import logging
from xmlUtils import XMLParser
#import xml.dom
@@ -37,6 +38,8 @@
timeTag = mainNS.substitute(tag="time")
trackTag = mainNS.substitute(tag="trk")
trackPointTag = mainNS.substitute(tag="trkpt")
+trackPointTagLast = mainNS.substitute(tag="trkpt[last()]")
+trackSegTag = mainNS.substitute(tag="trkseg")
elevationTag = mainNS.substitute(tag="ele")
nameTag = mainNS.substitute(tag="name")
@@ -107,6 +110,25 @@
def getCalories(self):
return self.calories
+
+ def getLaps(self):
+ logging.debug(">>")
+ lapInfo = []
+ tree = self.tree
+ date = tree.findtext(timeTag)
+ startTime = datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
+ trksegs = tree.findall(trackSegTag)
+ for trkseg in trksegs:
+ trkpts = trkseg.findall(trackPointTag)
+ trkpt = trkpts[-1]
+ lat = trkpt.get("lat")
+ lon = trkpt.get("lon")
+ temp = trkpt.findtext(timeTag)
+ time = datetime.strptime(temp, "%Y-%m-%dT%H:%M:%SZ")
+ elapsedTime = time - startTime
+ print "Found time: %s, lat: %s lon: %s" % (elapsedTime, lat, lon)
+ lapInfo.append((elapsedTime, lat, lon))
+ return lapInfo
def _getValues(self):
'''
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-11-30 10:02:45 UTC (rev 415)
+++ pytrainer/trunk/pytrainer/main.py 2009-12-01 09:41:27 UTC (rev 416)
@@ -97,7 +97,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#415"
+ self.version ="1.6.0.9_svn#416"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jb...@us...> - 2009-12-01 09:56:21
|
Revision: 417
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=417&view=rev
Author: jblance
Date: 2009-12-01 09:56:12 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Some interim lap progress
Modified Paths:
--------------
pytrainer/trunk/pytrainer/extensions/googlemaps.py
pytrainer/trunk/pytrainer/lib/gpx.py
pytrainer/trunk/pytrainer/main.py
Modified: pytrainer/trunk/pytrainer/extensions/googlemaps.py
===================================================================
--- pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-12-01 09:41:27 UTC (rev 416)
+++ pytrainer/trunk/pytrainer/extensions/googlemaps.py 2009-12-01 09:56:12 UTC (rev 417)
@@ -189,9 +189,9 @@
});\n'''
for lap in laps:
- lapNumber = laps.index(lap)
+ lapNumber = laps.index(lap)+1
content += "var lap%dmarker = new google.maps.Marker({position: new google.maps.LatLng(%f, %f), icon: lapimage, map: map, title:\"Lap%d\"}); \n " % (lapNumber, float(lap[1]), float(lap[2]), lapNumber)
- content += "var lap%d = new google.maps.InfoWindow({content: \"End of lap:%s<br>Elapsed time:%s\" });\n" % (lapNumber, lapNumber+1, lap[0])
+ content += "var lap%d = new google.maps.InfoWindow({content: \"End of lap:%s<br>Elapsed time:%s\" });\n" % (lapNumber, lapNumber, lap[0])
content += "google.maps.event.addListener(lap%dmarker, 'click', function() { lap%d.open(map,lap%dmarker); });\n" % (lapNumber,lapNumber,lapNumber)
content += '''
Modified: pytrainer/trunk/pytrainer/lib/gpx.py
===================================================================
--- pytrainer/trunk/pytrainer/lib/gpx.py 2009-12-01 09:41:27 UTC (rev 416)
+++ pytrainer/trunk/pytrainer/lib/gpx.py 2009-12-01 09:56:12 UTC (rev 417)
@@ -126,7 +126,7 @@
temp = trkpt.findtext(timeTag)
time = datetime.strptime(temp, "%Y-%m-%dT%H:%M:%SZ")
elapsedTime = time - startTime
- print "Found time: %s, lat: %s lon: %s" % (elapsedTime, lat, lon)
+ #print "Found time: %s, lat: %s lon: %s" % (elapsedTime, lat, lon)
lapInfo.append((elapsedTime, lat, lon))
return lapInfo
Modified: pytrainer/trunk/pytrainer/main.py
===================================================================
--- pytrainer/trunk/pytrainer/main.py 2009-12-01 09:41:27 UTC (rev 416)
+++ pytrainer/trunk/pytrainer/main.py 2009-12-01 09:56:12 UTC (rev 417)
@@ -97,7 +97,7 @@
def __init__(self,filename = None, data_path = None):
logging.debug('>>')
self.data_path = data_path
- self.version ="1.6.0.9_svn#416"
+ self.version ="1.6.0.9_svn#417"
self.date = Date()
main_dir = os.path.realpath(os.path.dirname(__file__)) #why?
sys.path.insert(0, main_dir) #why?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dg...@us...> - 2009-12-06 11:43:19
|
Revision: 426
http://pytrainer.svn.sourceforge.net/pytrainer/?rev=426&view=rev
Author: dgranda
Date: 2009-12-06 11:43:09 +0000 (Sun, 06 Dec 2009)
Log Message:
-----------
Fixed a problem with days encoding for weekly view. Extra logging added
Modified Paths:
--------------
pytrainer/trunk/pytrainer/gui/drawArea.py
pytrainer/trunk/pytrainer/gui/windowmain.py
pytrainer/trunk/pytrainer/weekgraph.py
Modified: pytrainer/trunk/pytrainer/gui/drawArea.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/drawArea.py 2009-12-05 13:20:57 UTC (rev 425)
+++ pytrainer/trunk/pytrainer/gui/drawArea.py 2009-12-06 11:43:09 UTC (rev 426)
@@ -156,6 +156,8 @@
#TODO tidy
logging.debug('>>')
logging.debug("Title: %s", (title, ))
+ logging.debug("X values received: %s", str(xvalues))
+ logging.debug("Y values received: %s", str(yvalues))
self.removeVboxChildren()
#Check how many axes to draw
@@ -168,7 +170,7 @@
else: #Error
return
- keys = yvalues[0].keys()
+ keys = yvalues[0].keys() # days of the week
numRows = len(keys)
numCols = len(xvalues[0])
if numRows == 0:
@@ -186,6 +188,7 @@
#Display first axis
for key in keys:
+ logging.debug("Day of the week: %s", str(key))
for ind in inds:
ybottoms[ind] += yheights[ind]
yheights[ind] = 0 #Zero heights
@@ -210,6 +213,9 @@
plt.title(title[0])
axis.legend(loc=0)
+ logging.debug("X values first axis: %s", str(xvals))
+ logging.debug("Y values first axis: %s", str(yheights))
+
#Display twin axis
if len(xvalues) == 2:
self.showGraph=False
Modified: pytrainer/trunk/pytrainer/gui/windowmain.py
===================================================================
--- pytrainer/trunk/pytrainer/gui/windowmain.py 2009-12-05 13:20:57 UTC (rev 425)
+++ pytrainer/trunk/pytrainer/gui/windowmain.py 2009-12-06 11:43:09 UTC (rev 426)
@@ -352,6 +352,7 @@
km = calories = time = average = beats = 0
num_records = len(record_list)
+ logging.info("Number of records selected week: "+str(num_records))
time_in_min = 0
tbeats = 0
maxspeed = 0
Modified: pytrainer/trunk/pytrainer/weekgraph.py
===================================================================
--- pytrainer/trunk/pytrainer/weekgraph.py 2009-12-05 13:20:57 UTC (rev 425)
+++ pytrainer/trunk/pytrainer/weekgraph.py 2009-12-06 11:43:09 UTC (rev 426)
@@ -35,6 +35,8 @@
tit = []
valsAreTime = []
+ logging.debug("Values: "+str(values))
+
#Reset the comboboxes if nothing selected
value_selected = self.combovalue.get_active()
if value_selected < 0:
@@ -54,6 +56,8 @@
#TODO
yvalues, valuesAreTime = self.get_values(values,value_selected)
+ logging.debug("yvalues: "+str(yvalues))
+ logging.debug("valuesAreTime: "+str(valuesAreTime))
yval.append(yvalues)
xlab.append(days)
valsAreTime.append(valuesAreTime)
@@ -78,7 +82,7 @@
valueCount = {} #Counts the totals to allow for averaging if needed
for record in values:
- day = datetime.datetime.strptime(record[0], "%Y-%m-%d").strftime("%a") # Gives Sun, Mon etc for this record
+ day = unicode(datetime.datetime.strptime(record[0], "%Y-%m-%d").strftime("%a")) # Gives Sun, Mon etc for this record
sport = record[9]
value = self.getValue(record, value_selected)
if sport in valueDict: #Already got this sport
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|