1
# -*- coding: iso-8859-1 -*-
3
#Copyright (C) Fiz Vazquez vud1@sindominio.net
6
#This program is free software; you can redistribute it and/or
7
#modify it under the terms of the GNU General Public License
8
#as published by the Free Software Foundation; either version 2
9
#of the License, or (at your option) any later version.
11
#This program is distributed in the hope that it will be useful,
12
#but WITHOUT ANY WARRANTY; without even the implied warranty of
13
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
#GNU General Public License for more details.
16
#You should have received a copy of the GNU General Public License
17
#along with this program; if not, write to the Free Software
18
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
import os, sys, commands
23
from lxml import etree
24
import dateutil.parser
25
from dateutil.tz import * # for tzutc()
27
from pytrainer.lib.system import checkConf
30
def __init__(self, parent = None, data_path = None):
32
self.conf = checkConf()
33
self.tmpdir = self.conf.getValue("tmpdir")
34
self.main_data_path = data_path
35
self.data_path = os.path.dirname(__file__)
41
result = commands.getstatusoutput('gpsbabel -V')
43
version = result[1].split()
47
logging.error("Unexpected result from gpsbabel -V")
51
def getSourceLocation(self):
52
return "http://www.gpsbabel.org/"
54
def deviceExists(self):
56
#TODO Check if this is correct???
57
outmod = commands.getstatusoutput('/sbin/lsmod | grep garmin_gps')
58
if outmod[0]==256: #there is no garmin_gps module loaded
71
def getDateTime(self, time_):
72
# Time can be in multiple formats
73
# - zulu 2009-12-15T09:00Z
74
# - local ISO8601 2009-12-15T10:00+01:00
75
if time_ is None or time_ == "":
77
dateTime = dateutil.parser.parse(time_)
78
timezone = dateTime.tzname()
79
if timezone == 'UTC': #got a zulu time
80
local_dateTime = dateTime.astimezone(tzlocal()) #datetime with localtime offset (from OS)
82
local_dateTime = dateTime #use datetime as supplied
83
utc_dateTime = dateTime.astimezone(tzutc()) #datetime with 00:00 offset
84
return (utc_dateTime,local_dateTime)