Exemplo n.º 1
0
 def get_value(self, param):
     ''' Function to get the value of various params in this activity instance
             Automatically returns values converted to imperial if needed
     '''
     if param == 'distance':
         return self.uc.distance(self.distance)
     elif param == 'average':
         return self.uc.speed(self.average)
     elif param == 'upositive':
         return self.uc.height(self.upositive)
     elif param == 'unegative':
         return self.uc.height(self.unegative)
     elif param == 'maxspeed':
         return self.uc.speed(self.maxspeed)
     elif param == 'maxpace':
         return uc.float2pace(self.uc.pace(self.maxpace))
     elif param == 'pace':
         return uc.float2pace(self.uc.pace(self.pace))
     elif param == 'calories':
         return self.calories
     elif param == 'time':
         if not self.duration:
             return ""
         _hour, _min, _sec = second2time(self.duration)
         if _hour == 0:
             return "%02d:%02d" % (_min, _sec)
         else:
             return "%0d:%02d:%02d" % (_hour, _min, _sec)
     else:
         logging.error(
             "Unable to provide value for unknown parameter (%s) for activity",
             param)
         return None
Exemplo n.º 2
0
 def get_value(self, param):
     ''' Function to get the value of various params in this activity instance
             Automatically returns values converted to imperial if needed
     '''
     if param == 'distance':
         return self.uc.distance(self.distance)
     elif param == 'average':
         return self.uc.speed(self.average)
     elif param == 'upositive':
         return self.uc.height(self.upositive)
     elif param == 'unegative':
         return self.uc.height(self.unegative)
     elif param == 'maxspeed':
         return self.uc.speed(self.maxspeed)
     elif param == 'maxpace':
         return uc.float2pace(self.uc.pace(self.maxpace))
     elif param == 'pace':
         return uc.float2pace(self.uc.pace(self.pace))
     elif param == 'calories':
         return self.calories
     elif param == 'time':
         if not self.duration:
             return ""
         _hour ,_min, _sec = second2time(self.duration)
         if _hour == 0:
             return "%02d:%02d" % (_min, _sec)
         else:
             return "%0d:%02d:%02d" % (_hour, _min, _sec)
     else:
         logging.error("Unable to provide value for unknown parameter (%s) for activity", param)
         return None