Beispiel #1
0
    def __init__(self,
                 input_dir,
                 debug,
                 latest=False,
                 recursive=False,
                 fit_types=None,
                 measurement_system=fitfile.field_enums.DisplayMeasure.metric):
        """
        Return an instance of FitData.

        Parameters:
        input_dir (string): directory (full path) to check for monitoring data files
        debug (Boolean): enable debug logging
        latest (Boolean): check for latest files only
        fit_types (Fit.field_enums.FileType): check for this file type only
        measurement_system (enum): which measurement system to use when importing the files

        """
        logger.info("Processing %s FIT data from %s", fit_types, input_dir)
        self.measurement_system = measurement_system
        self.debug = debug
        self.fit_types = fit_types
        self.file_names = FileProcessor.dir_to_files(input_dir,
                                                     fitfile.file.name_regex,
                                                     latest, recursive)
Beispiel #2
0
 def __init__(self, input_file, input_dir, db_params, metric, debug):
     """Return a new instance of FitBitData given the location of the data files, paramters for accessing the database, and if the data should be stored in metric units."""
     self.metric = metric
     self.fitbitdb = FitBitDb(db_params, debug)
     if input_file:
         self.file_names = FileProcessor.match_file(input_file, r'.*\.csv')
     if input_dir:
         self.file_names = FileProcessor.dir_to_files(input_dir, r'.*\.csv')
Beispiel #3
0
 def __copy(self, src_dir, dest_dir, latest=False):
     """Copy FIT files from a USB mounted Garmin device to the given directory."""
     file_names = FileProcessor.dir_to_files(src_dir,
                                             fitfile.file.name_regex,
                                             latest)
     logger.info("Copying files from %s to %s", src_dir, dest_dir)
     for file in tqdm(file_names, unit='files'):
         shutil.copy(file, dest_dir)
Beispiel #4
0
 def __init__(self, input_file, input_dir, db_params, metric, debug):
     """Return an instance of MSHealthData given an input file or files and information on the databse to put it in."""
     self.metric = metric
     self.mshealth_db = MSHealthDb(db_params, debug)
     if input_file:
         self.file_names = FileProcessor.match_file(input_file, r'Daily_Summary_.*\.csv')
     if input_dir:
         self.file_names = FileProcessor.dir_to_files(input_dir, r'Daily_Summary_.*\.csv')
Beispiel #5
0
 def __init__(self, input_file, input_dir, db_params, metric, debug):
     """Return an instance of MSVaultData given an input file or files and information on the databse to put it in."""
     self.metric = metric
     self.mshealth_db = MSHealthDb(db_params, debug)
     self.cols_map = {
         'Date': ('timestamp', CsvImporter.map_mdy_date),
         'Weight': ('weight', MSVaultData.__map_weight),
     }
     if input_file:
         self.file_names = FileProcessor.match_file(input_file, r'HealthVault_Weight_.*\.csv')
     if input_dir:
         self.file_names = FileProcessor.dir_to_files(input_dir, r'HealthVault_Weight_.*\.csv')
Beispiel #6
0
 def test_parse_unknown(self):
     # root_logger.setLevel(logging.DEBUG)
     activity_path = self.file_path + '/unknown'
     file_names = FileProcessor.dir_to_files(activity_path, fitfile.file.name_regex, False)
     for file_name in file_names:
         self.check_unknown_file(file_name)
Beispiel #7
0
 def test_parse_sleep(self):
     activity_path = self.file_path + '/sleep'
     file_names = FileProcessor.dir_to_files(activity_path, fitfile.file.name_regex, False)
     for file_name in file_names:
         self.check_sleep_file(file_name)
Beispiel #8
0
 def test_parse_monitoring(self):
     monitoring_path = self.file_path + '/monitoring'
     file_names = FileProcessor.dir_to_files(monitoring_path, fitfile.file.name_regex, False)
     for file_name in file_names:
         self.check_monitoring_file(file_name)
Beispiel #9
0
 def test_parse_tcx(self):
     file_names = FileProcessor.dir_to_files(self.file_path,
                                             self.tcx_filename_regex, False)
     for file_name in file_names:
         self.check_activity_file(file_name)