Chore: update environment configuration for local development; modify Dockerfile to streamline SDK installation and enhance startup script for better directory handling; add time verification script for system time synchronization
This commit is contained in:
@@ -3,23 +3,17 @@ FROM python:3.11-slim
|
||||
|
||||
# Install system dependencies required by SDK and tooling
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash ca-certificates tar \
|
||||
bash ca-certificates tar sudo \
|
||||
libusb-1.0-0 libgl1 libx11-6 libxext6 libxcb1 libgtk-3-0 \
|
||||
libusb-1.0-0-dev udev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy SDK bundle placed under api/camera_sdk and install native libs
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
COPY camera_sdk /tmp/camera_sdk
|
||||
|
||||
RUN set -eux; \
|
||||
mkdir -p /opt/mvsdk; \
|
||||
TARBALL="$(find /tmp/camera_sdk -maxdepth 1 -type f -name '*.tar.gz' | head -n1)"; \
|
||||
if [ -z "$TARBALL" ]; then echo 'No SDK .tar.gz found in camera_sdk'; exit 1; fi; \
|
||||
tar -xzf "$TARBALL" -C /opt/mvsdk || true; \
|
||||
# Copy any .so library files into /usr/lib so ctypes can load libMVSDK.so
|
||||
find /opt/mvsdk -type f -name '*.so*' -exec cp -n {} /usr/lib/ \; || true; \
|
||||
ldconfig || true
|
||||
# Set environment variables for library paths and Python path
|
||||
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/lib
|
||||
ENV PYTHONPATH=/app:/app/camera_sdk
|
||||
|
||||
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
|
||||
|
||||
# The actual app code is bind-mounted by docker-compose at runtime
|
||||
# The actual app code and SDK will be bind-mounted by docker-compose at runtime
|
||||
# SDK installation will be handled in the docker-compose command
|
||||
|
||||
58
camera-management-api/check_time.py
Executable file
58
camera-management-api/check_time.py
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Time verification script for USDA Vision Camera System
|
||||
Checks if system time is properly synchronized
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import pytz
|
||||
import requests
|
||||
import json
|
||||
|
||||
def check_system_time():
|
||||
"""Check system time against multiple sources"""
|
||||
print("🕐 USDA Vision Camera System - Time Verification")
|
||||
print("=" * 50)
|
||||
|
||||
# Get local time
|
||||
local_time = datetime.datetime.now()
|
||||
utc_time = datetime.datetime.utcnow()
|
||||
|
||||
# Get Atlanta timezone
|
||||
atlanta_tz = pytz.timezone('America/New_York')
|
||||
atlanta_time = datetime.datetime.now(atlanta_tz)
|
||||
|
||||
print(f"Local system time: {local_time}")
|
||||
print(f"UTC time: {utc_time}")
|
||||
print(f"Atlanta time: {atlanta_time}")
|
||||
print(f"Timezone: {atlanta_time.tzname()}")
|
||||
|
||||
# Check against world time API
|
||||
try:
|
||||
print("\n🌐 Checking against world time API...")
|
||||
response = requests.get("http://worldtimeapi.org/api/timezone/America/New_York", timeout=5)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
api_time = datetime.datetime.fromisoformat(data['datetime'].replace('Z', '+00:00'))
|
||||
|
||||
# Compare times (allow 5 second difference)
|
||||
time_diff = abs((atlanta_time.replace(tzinfo=None) - api_time.replace(tzinfo=None)).total_seconds())
|
||||
|
||||
print(f"API time: {api_time}")
|
||||
print(f"Time difference: {time_diff:.2f} seconds")
|
||||
|
||||
if time_diff < 5:
|
||||
print("✅ Time is synchronized (within 5 seconds)")
|
||||
return True
|
||||
else:
|
||||
print("❌ Time is NOT synchronized (difference > 5 seconds)")
|
||||
return False
|
||||
else:
|
||||
print("⚠️ Could not reach time API")
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"⚠️ Error checking time API: {e}")
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_system_time()
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"mqtt": {
|
||||
"broker_host": "mqtt",
|
||||
"broker_host": "192.168.1.110",
|
||||
"broker_port": 1883,
|
||||
"username": null,
|
||||
"password": null,
|
||||
@@ -89,5 +89,4 @@
|
||||
"hdr_gain_mode": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
echo "USDA Vision Camera System - Startup Script"
|
||||
echo "=========================================="
|
||||
# Ensure we are running from the script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
echo "📂 Working directory: $SCRIPT_DIR"
|
||||
|
||||
|
||||
# Check if virtual environment exists
|
||||
if [ ! -d ".venv" ]; then
|
||||
@@ -14,6 +19,9 @@ fi
|
||||
# Activate virtual environment
|
||||
echo "🔧 Activating virtual environment..."
|
||||
source .venv/bin/activate
|
||||
# Ensure project root is on PYTHONPATH for imports
|
||||
export PYTHONPATH="$SCRIPT_DIR:$PYTHONPATH"
|
||||
|
||||
|
||||
# Check if config file exists
|
||||
if [ ! -f "config.json" ]; then
|
||||
@@ -30,11 +38,11 @@ fi
|
||||
|
||||
# Check time synchronization
|
||||
echo "🕐 Checking time synchronization..."
|
||||
python check_time.py
|
||||
python tests/core/check_time.py
|
||||
echo ""
|
||||
# Run system tests first
|
||||
echo "🧪 Running system tests..."
|
||||
python test_system.py
|
||||
python tests/integration/test_system.py
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ System tests failed. Please check the configuration."
|
||||
|
||||
Reference in New Issue
Block a user