Esempio n. 1
0
 def get_activities(self, directory, count, overwite=False):
     """Download activities files from Garmin Connect and save the raw files."""
     self.temp_dir = tempfile.mkdtemp()
     logger.info("Geting activities: '%s' (%d) temp %s", directory, count,
                 self.temp_dir)
     activities = self.__get_activity_summaries(0, count)
     for activity in tqdm(activities, unit='activities'):
         activity_id_str = str(activity['activityId'])
         activity_name_str = conversions.printable(activity['activityName'])
         root_logger.info("get_activities: %s (%s)", activity_name_str,
                          activity_id_str)
         json_filename = f'{directory}/activity_{activity_id_str}.json'
         if not os.path.isfile(json_filename) or overwite:
             root_logger.info("get_activities: %s <- %r", json_filename,
                              activity)
             self.__save_activity_details(directory, activity_id_str,
                                          overwite)
             self.modern_rest_client.save_json_to_file(
                 json_filename, activity)
             if not os.path.isfile(
                     f'{directory}/{activity_id_str}.fit') or overwite:
                 self.__save_activity_file(activity_id_str)
             # pause for a second between every page access
             time.sleep(1)
     self.__unzip_files(directory)
Esempio n. 2
0
 def get_activities(self, directory, count, overwite=False):
     """Download activities files from Garmin Connect and save the raw files."""
     logger.info("Geting activities: '%s' (%d)", directory, count)
     activities = self.__get_activity_summaries(0, count)
     for activity in progressbar.progressbar(activities):
         activity_id_str = str(activity['activityId'])
         activity_name_str = conversions.printable(activity['activityName'])
         root_logger.info("get_activities: %s (%s)" % (activity_name_str, activity_id_str))
         json_filename = directory + '/activity_' + activity_id_str + '.json'
         if not os.path.isfile(json_filename) or overwite:
             root_logger.info("get_activities: %s <- %r" % (json_filename, activity))
             self.__save_activity_details(directory, activity_id_str, overwite)
             self.rest_client.save_json_to_file(json_filename, activity)
             if not os.path.isfile(directory + '/' + activity_id_str + '.fit') or overwite:
                 self.__save_activity_file(activity_id_str)
             # pause for a second between every page access
             time.sleep(1)