From bb6db12c7701d73a7e9bb924900d7a1fcf195194 Mon Sep 17 00:00:00 2001 From: AlaskaJedi <15811021+AlaskaJedi@users.noreply.github.com> Date: Mon, 25 Dec 2023 22:25:06 -0900 Subject: [PATCH 1/3] Update sync.py Error accessing variable 'gar_wg_state' when only using Withings blood pressure device. Moved set_lastsyn() under reach fit_data if statements so the other variable isn't used.. UnboundLocalError: cannot access local variable 'gar_wg_state' where it is not associated with a value --- withings_sync/sync.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/withings_sync/sync.py b/withings_sync/sync.py index 711450e..281709f 100644 --- a/withings_sync/sync.py +++ b/withings_sync/sync.py @@ -464,16 +464,19 @@ def sync(): logging.info( "Fit file with weight information uploaded to Garmin Connect" ) + # Save this sync so we don't re-download the same data again (if no range has been specified) + if not ARGS.fromdate: + withings.set_lastsync() + if fit_data_blood_pressure is not None: gar_bp_state = sync_garmin(fit_data_blood_pressure) if gar_bp_state: logging.info( "Fit file with blood pressure information uploaded to Garmin Connect" ) - if gar_wg_state or gar_bp_state: - # Save this sync so we don't re-download the same data again (if no range has been specified) - if not ARGS.fromdate: - withings.set_lastsync() + # Save this sync so we don't re-download the same data again (if no range has been specified) + if not ARGS.fromdate: + withings.set_lastsync() else: logging.info("No Garmin username - skipping sync") else: From cb1cd1d2e487681873d2393728383c181cb46098 Mon Sep 17 00:00:00 2001 From: AlaskaJedi <15811021+AlaskaJedi@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:06:04 -0900 Subject: [PATCH 2/3] Added gar_wg_state and gar_bp_state variables Error accessing variable 'gar_wg_state' when only using Withings blood pressure device. Added variables to prevent this. UnboundLocalError: cannot access local variable 'gar_wg_state' where it is not associated with a value --- withings_sync/sync.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/withings_sync/sync.py b/withings_sync/sync.py index 281709f..3ff1f24 100644 --- a/withings_sync/sync.py +++ b/withings_sync/sync.py @@ -458,16 +458,14 @@ def sync(): fit_data_weight is not None or fit_data_blood_pressure is not None ): logging.debug("attempting to upload fit file...") + gar_wg_state = None + gar_bp_state = None if fit_data_weight is not None: gar_wg_state = sync_garmin(fit_data_weight) if gar_wg_state: logging.info( "Fit file with weight information uploaded to Garmin Connect" ) - # Save this sync so we don't re-download the same data again (if no range has been specified) - if not ARGS.fromdate: - withings.set_lastsync() - if fit_data_blood_pressure is not None: gar_bp_state = sync_garmin(fit_data_blood_pressure) if gar_bp_state: @@ -475,8 +473,10 @@ def sync(): "Fit file with blood pressure information uploaded to Garmin Connect" ) # Save this sync so we don't re-download the same data again (if no range has been specified) - if not ARGS.fromdate: - withings.set_lastsync() + if gar_wg_state or gar_bp_state: + # Save this sync so we don't re-download the same data again (if no range has been specified) + if not ARGS.fromdate: + withings.set_lastsync() else: logging.info("No Garmin username - skipping sync") else: From 0fd7e7bf83827048ef1dbabb6e3fd616b14f8fd6 Mon Sep 17 00:00:00 2001 From: AlaskaJedi <15811021+AlaskaJedi@users.noreply.github.com> Date: Wed, 27 Dec 2023 09:54:34 -0900 Subject: [PATCH 3/3] Removed extra comment Removed unneeded comment --- withings_sync/sync.py | 1 - 1 file changed, 1 deletion(-) diff --git a/withings_sync/sync.py b/withings_sync/sync.py index 3ff1f24..dc8ef1b 100644 --- a/withings_sync/sync.py +++ b/withings_sync/sync.py @@ -472,7 +472,6 @@ def sync(): logging.info( "Fit file with blood pressure information uploaded to Garmin Connect" ) - # Save this sync so we don't re-download the same data again (if no range has been specified) if gar_wg_state or gar_bp_state: # Save this sync so we don't re-download the same data again (if no range has been specified) if not ARGS.fromdate: