from lxml import etree
from urllib2 import unquote
import pygpx
-import pyosmname
+import pygeocode
import sqlite3
import datetime
print "processing..."
start = track.start()
if start:
- printable = pyosmname.GeoName(start.lat,start.lon).printable
+ printable = pygeocode.GeoName(start.lat,start.lon).printable
start_time = track.start_time()
full_duration = track.full_duration().total_seconds()
distance = track.distance()
trainings = []
req = requests.get("http://www.gps-sport.net/services/getMonthlyTrainingDataHTML_V2.jsp?userName=%s&year=%s&month=%s&rnd=0.645673"% (uname,year,month), headers = {'User-agent': 'Mozilla/5.0'})
- page = req.text.encode()
+ print req.text
+ page = req.text.encode('utf-8')
dom = html.document_fromstring(page)
for element, attribute, link, pos in dom.iterlinks():
print "trid=",trid
req = requests.get("http://www.gps-sport.net/services/trainingGPX.jsp?trainingID=%s&tz=-180" % (trid))
- xml = etree.fromstring(req.text.encode())
+ xml = etree.fromstring(req.text.encode('utf-8'))
return xml
req = requests.get(url,auth=(username,password))
- xml = etree.fromstring(req.text.encode())
+ xml = etree.fromstring(req.text.encode('utf-8'))
res=[]
url = "https://www.openstreetmap.org/api/0.6/gpx/"+track_id+"/data"
req = requests.get(url,auth=(username,password))
- xml = etree.fromstring(req.text.encode())
+ xml = etree.fromstring(req.text.encode('utf-8'))
return xml
os.remove(tmp_gpx_name)
os.remove(tmp_tcx_name)
- xml = etree.fromstring(data.encode())
+ xml = etree.fromstring(data.encode('utf-8'))
return xml
def get_dbx_list(dbx,username,year,month):
training_list = get_page(username,year,month)
for tr in training_list:
+ try:
filename = "%s/%04d/%02d/%s_%s.gpx" % (dir,year,(month+1),tr[0],tr[1])
dirname = "%s/%04d/%02d" % (dir,year,(month+1))
gpx = pygpx.GPX()
gpx.ReadTree(xml)
- sport = training['sport']
+ sport = tr[0]
timestamp = gpx.tracks[0].start_time()
if check_db_for_training(db,sport,timestamp):
except:
None
+ except:
+ raise
+
def main():
global db;