def test_parse_unknown(self): # root_logger.setLevel(logging.DEBUG) activity_path = self.file_path + '/unknown' file_names = FileProcessor.dir_to_files(activity_path, Fit.file.name_regex, False) for file_name in file_names: self.check_unknown_file(file_name)
def __init__(self, input_dir, debug, latest=False, recursive=False, fit_types=None, measurement_system=Fit.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, Fit.file.name_regex, latest, recursive)
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, Fit.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)
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.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')
def __init__(self, input_file, input_dir, db_params_dict, 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.FitBitDB(db_params_dict, 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')
def copy_monitoring(self, monitoring_dir, latest): """Copy daily monitoring data FIT files from a USB mounted Garmin device to the given directory.""" device_monitoring_dir = GarminDBConfigManager.device_monitoring_dir( self.device_mount_dir) logger.info("Copying monitoring files from %s to %s", device_monitoring_dir, monitoring_dir) file_names = FileProcessor.dir_to_files(device_monitoring_dir, Fit.file.name_regex, latest) for file in progressbar.progressbar(file_names): shutil.copy(file, monitoring_dir)
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.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')
def __init__(self, input_dir, latest, measurement_system, debug): """ Return an instance of GarminMonitoringFitData. Parameters: input_dir (string): directory (full path) to check for monitoring data files latest (Boolean): check for latest files only measurement_system (enum): which measurement system to use when importing the files debug (Boolean): enable debug logging """ logger.info("Processing daily monitoring FIT data") self.measurement_system = measurement_system self.debug = debug if input_dir: self.file_names = FileProcessor.dir_to_files( input_dir, Fit.file.name_regex, latest, True)
def __init__(self, input_dir, latest, measurement_system, debug): """ Return an instance of GarminTcxData. Parameters: db_params_dict (dict): configuration data for accessing the database input_dir (string): directory (full path) to check for data files latest (Boolean): check for latest files only measurement_system (enum): which measurement system to use when importing the files debug (Boolean): enable debug logging """ logger.debug("Processing activities tcx data") self.measurement_system = measurement_system self.debug = debug if input_dir: self.file_names = FileProcessor.dir_to_files(input_dir, self.tcx_filename_regex, latest)
def test_parse_activity(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)
def test_parse_sleep(self): activity_path = self.file_path + '/sleep' file_names = FileProcessor.dir_to_files(activity_path, Fit.file.name_regex, False) for file_name in file_names: self.check_sleep_file(file_name)
def test_parse_monitoring(self): monitoring_path = self.file_path + '/monitoring' file_names = FileProcessor.dir_to_files(monitoring_path, Fit.file.name_regex, False) for file_name in file_names: self.check_monitoring_file(file_name)