Skip to content

Commit 70386f1

Browse files
authored
Merge pull request #295 from cyberjunky/revamp
Added activity file selector to demo, removed black
2 parents 749c248 + b346f03 commit 70386f1

File tree

7 files changed

+92
-355
lines changed

7 files changed

+92
-355
lines changed

.coderabbit.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
language: "en-US"
33
early_access: true
44
reviews:
5-
profile: "pythonic"
5+
profile: "assertive"
66
request_changes_workflow: true
77
high_level_summary: true
88
poem: false
@@ -11,11 +11,7 @@ reviews:
1111
auto_review:
1212
enabled: true
1313
drafts: false
14-
auto_fix:
15-
enabled: true
16-
include_imports: true
17-
include_type_hints: true
18-
include_security_fixes: true
14+
1915
path_filters:
2016
- "!tests/**/cassettes/**"
2117
path_instructions:

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,17 @@ jobs:
6161
# pdm run coverage xml
6262
# continue-on-error: true
6363

64+
- name: Check for coverage report
65+
id: coverage_check
66+
run: |
67+
if [ -f coverage.xml ]; then
68+
echo "coverage_generated=true" >> "$GITHUB_OUTPUT"
69+
else
70+
echo "coverage_generated=false" >> "$GITHUB_OUTPUT"
71+
fi
72+
6473
- name: Upload coverage artifact
65-
if: matrix.python-version == '3.11'
74+
if: matrix.python-version == '3.11' && steps.coverage_check.outputs.coverage_generated == 'true'
6675
uses: actions/upload-artifact@v4
6776
with:
6877
name: coverage-xml

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ repos:
1818
- tomli
1919
exclude: 'cassettes/'
2020

21-
- repo: https://github.com/psf/black
22-
rev: 24.8.0
23-
hooks:
24-
- id: black
25-
language_version: python3
21+
# Removed black - using ruff-format instead to avoid formatting conflicts
22+
# - repo: https://github.com/psf/black
23+
# rev: 24.8.0
24+
# hooks:
25+
# - id: black
26+
# language_version: python3
2627

2728
- repo: https://github.com/astral-sh/ruff-pre-commit
2829
rev: v0.6.4
@@ -35,7 +36,7 @@ repos:
3536
hooks:
3637
- id: mypy
3738
name: mypy type checking
38-
entry: .venv/bin/pdm run mypy garminconnect tests
39+
entry: pdm run mypy garminconnect tests
3940
types: [python]
4041
language: system
4142
pass_filenames: false

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pdm install --group :all
210210
```
211211

212212
**Run Tests:**
213+
213214
```bash
214215
pdm run test # Run all tests
215216
pdm run testcov # Run tests with coverage report
@@ -232,6 +233,7 @@ pdm run test
232233
For package maintainers:
233234

234235
**Setup PyPI credentials:**
236+
235237
```bash
236238
pip install twine
237239
# Edit with your preferred editor, or create via here-doc:
@@ -241,6 +243,7 @@ pip install twine
241243
# password = <PyPI_API_TOKEN>
242244
# EOF
243245
```
246+
244247
```ini
245248
[pypi]
246249
username = __token__
@@ -256,11 +259,13 @@ export TWINE_PASSWORD="<PyPI_API_TOKEN>"
256259
```
257260

258261
**Publish new version:**
262+
259263
```bash
260264
pdm run publish # Build and publish to PyPI
261265
```
262266

263267
**Alternative publishing steps:**
268+
264269
```bash
265270
pdm run build # Build package only
266271
pdm publish # Publish pre-built package

demo.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def __init__(self):
7070

7171
# Activity settings
7272
self.activitytype = "" # Possible values: cycling, running, swimming, multi_sport, fitness_equipment, hiking, walking, other
73-
self.activityfile = (
74-
"test_data/sample_activity.gpx" # Supported file types: .fit .gpx .tcx
75-
)
73+
self.activityfile = "test_data/*.gpx" # Supported file types: .fit .gpx .tcx
7674
self.workoutfile = "test_data/sample_workout.json" # Sample workout JSON file
7775

7876
# Export settings
@@ -1288,37 +1286,42 @@ def get_solar_data(api: Garmin) -> None:
12881286

12891287
def upload_activity_file(api: Garmin) -> None:
12901288
"""Upload activity data from file."""
1289+
import glob
1290+
12911291
try:
1292-
# Default activity file from config
1293-
print(f"📤 Uploading activity from file: {config.activityfile}")
1292+
# List all .gpx files in test_data
1293+
gpx_files = glob.glob(config.activityfile)
1294+
if not gpx_files:
1295+
print("❌ No .gpx files found in test_data directory.")
1296+
print("ℹ️ Please add GPX files to test_data before uploading.")
1297+
return
12941298

1295-
# Check if file exists
1296-
import os
1299+
print("Select a GPX file to upload:")
1300+
for idx, fname in enumerate(gpx_files, 1):
1301+
print(f" {idx}. {fname}")
12971302

1298-
if not os.path.exists(config.activityfile):
1299-
print(f"❌ File not found: {config.activityfile}")
1300-
print(
1301-
"ℹ️ Please place your activity file (.fit, .gpx, or .tcx) under the 'test_data' directory or update config.activityfile"
1302-
)
1303-
print("ℹ️ Supported formats: FIT, GPX, TCX")
1304-
return
1303+
while True:
1304+
try:
1305+
choice = int(input(f"Enter number (1-{len(gpx_files)}): "))
1306+
if 1 <= choice <= len(gpx_files):
1307+
selected_file = gpx_files[choice - 1]
1308+
break
1309+
else:
1310+
print("Invalid selection. Try again.")
1311+
except ValueError:
1312+
print("Please enter a valid number.")
13051313

1306-
# Upload the activity
1307-
result = api.upload_activity(config.activityfile)
1314+
print(f"📤 Uploading activity from file: {selected_file}")
13081315

1309-
if result:
1310-
print("✅ Activity uploaded successfully!")
1311-
call_and_display(
1312-
api.upload_activity,
1313-
config.activityfile,
1314-
method_name="upload_activity",
1315-
api_call_desc=f"api.upload_activity({config.activityfile})",
1316-
)
1317-
else:
1318-
print(f"❌ Failed to upload activity from {config.activityfile}")
1316+
call_and_display(
1317+
api.upload_activity,
1318+
selected_file,
1319+
method_name="upload_activity",
1320+
api_call_desc=f"api.upload_activity({selected_file})",
1321+
)
13191322

13201323
except FileNotFoundError:
1321-
print(f"❌ File not found: {config.activityfile}")
1324+
print(f"❌ File not found: {selected_file}")
13221325
print("ℹ️ Please ensure the activity file exists in the current directory")
13231326
except requests.exceptions.HTTPError as e:
13241327
if e.response.status_code == 409:
@@ -1363,7 +1366,6 @@ def upload_activity_file(api: Garmin) -> None:
13631366
print(f"❌ Too many requests: {e}")
13641367
print("💡 Please wait a few minutes before trying again")
13651368
except Exception as e:
1366-
# Check if this is a wrapped HTTP error from the Garmin library
13671369
error_str = str(e)
13681370
if "409 Client Error: Conflict" in error_str:
13691371
print(

0 commit comments

Comments
 (0)