sync
This commit is contained in:
94
fitbitsync_debug.py
Normal file
94
fitbitsync_debug.py
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug script to test Fitbit library installation and functionality
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
def test_fitbit_import():
|
||||
"""Test importing the fitbit library"""
|
||||
print("Testing Fitbit library import...")
|
||||
|
||||
try:
|
||||
import fitbit
|
||||
print("✅ Successfully imported 'fitbit' module")
|
||||
print(f" Version: {getattr(fitbit, '__version__', 'Unknown')}")
|
||||
print(f" Location: {fitbit.__file__}")
|
||||
except ImportError as e:
|
||||
print(f"❌ Failed to import 'fitbit': {e}")
|
||||
return False
|
||||
|
||||
try:
|
||||
from fitbit.api import FitbitOauth2Client
|
||||
print("✅ Successfully imported 'FitbitOauth2Client'")
|
||||
except ImportError as e:
|
||||
print(f"❌ Failed to import 'FitbitOauth2Client': {e}")
|
||||
return False
|
||||
|
||||
try:
|
||||
# Test creating a basic client
|
||||
client = fitbit.Fitbit("test_id", "test_secret")
|
||||
print("✅ Successfully created basic Fitbit client")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to create basic Fitbit client: {e}")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def test_oauth_client():
|
||||
"""Test creating OAuth client"""
|
||||
print("\nTesting OAuth client creation...")
|
||||
|
||||
try:
|
||||
from fitbit.api import FitbitOauth2Client
|
||||
oauth_client = FitbitOauth2Client(
|
||||
"test_id",
|
||||
"test_secret",
|
||||
redirect_uri="http://localhost:8080/callback"
|
||||
)
|
||||
print("✅ Successfully created OAuth client")
|
||||
|
||||
# Test getting authorization URL
|
||||
try:
|
||||
auth_url, state = oauth_client.authorize_token_url()
|
||||
print("✅ Successfully generated authorization URL")
|
||||
print(f" Sample URL: {auth_url[:100]}...")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to generate authorization URL: {e}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to create OAuth client: {e}")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def main():
|
||||
print("🔍 Fitbit Library Debug Script")
|
||||
print("=" * 50)
|
||||
|
||||
print(f"Python version: {sys.version}")
|
||||
print(f"Python executable: {sys.executable}")
|
||||
print()
|
||||
|
||||
# Test basic import
|
||||
if not test_fitbit_import():
|
||||
print("\n💡 Installation suggestion:")
|
||||
print(" pip install fitbit")
|
||||
print(" or")
|
||||
print(" pip install python-fitbit")
|
||||
return
|
||||
|
||||
# Test OAuth functionality
|
||||
if not test_oauth_client():
|
||||
print("\n❌ OAuth client test failed")
|
||||
return
|
||||
|
||||
print("\n✅ All tests passed! Fitbit library should work correctly.")
|
||||
print("\n🔧 If you're still having issues, try:")
|
||||
print(" 1. Reinstalling: pip uninstall fitbit && pip install fitbit")
|
||||
print(" 2. Using a virtual environment")
|
||||
print(" 3. Checking for conflicting packages")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user