Added dynamic platform loader
This commit is contained in:
parent
8f976721ab
commit
6b47c3f555
@ -1,9 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import random
|
||||
import os
|
||||
import os.path
|
||||
from .abcactuator import AbcActuator
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformPlaybackDriver, BirbnetesIoTPlatformStatusDriver
|
||||
from utils import BirbnetesIoTPlatformPlaybackDriver, BirbnetesIoTPlatformStatusDriver
|
||||
|
||||
"""
|
||||
Abstract base class for Sender
|
||||
|
@ -6,7 +6,7 @@ import sentry_sdk
|
||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||
from utils import LoopingTimer
|
||||
from signal_processor import SoundSignalProcessor
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver
|
||||
from utils import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver
|
||||
from actuator import Loudspeaker
|
||||
import paho.mqtt.client
|
||||
import json
|
||||
|
@ -15,7 +15,7 @@ if not config.DISABLE_AI:
|
||||
from pyAudioAnalysis import MidTermFeatures
|
||||
import numpy
|
||||
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver
|
||||
from utils import BirbnetesIoTPlatformStatusDriver
|
||||
|
||||
"""
|
||||
Abstract base class for Sender
|
||||
@ -150,7 +150,7 @@ class SoundPreProcessorLegit(AbcPreProcessor):
|
||||
class SoundPreProcessorDummy(AbcPreProcessor):
|
||||
|
||||
def __init__(self):
|
||||
print("AI is disabled! Initializing dummy sound pre-processor...")
|
||||
logging.info("AI is disabled! Initializing dummy sound pre-processor...")
|
||||
|
||||
def preprocesssignal(self, file_path) -> bool:
|
||||
return True
|
||||
|
@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
from typing import Optional
|
||||
from .abcsensor import AbcSensor
|
||||
from utils import config
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformRecordDriver
|
||||
from utils import config, BirbnetesIoTPlatformRecordDriver
|
||||
|
||||
"""
|
||||
Sound sensor high level API
|
||||
|
@ -7,7 +7,7 @@ from preprocessor import SoundPreProcessor
|
||||
from .abcsignalprocessor import AbcSignalProcessor
|
||||
import os
|
||||
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver
|
||||
from utils import BirbnetesIoTPlatformStatusDriver
|
||||
|
||||
"""
|
||||
Abstract base class for signalprocessor
|
||||
|
@ -1,2 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
from .loopingtimer import LoopingTimer
|
||||
from .platform import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \
|
||||
BirbnetesIoTPlatformPlaybackDriver
|
||||
|
@ -34,3 +34,5 @@ REPORT_URL = os.environ.get("REPORT_URL", None)
|
||||
REPORT_INTERVAL = float(os.environ.get("REPORT_INTERVAL", 15))
|
||||
|
||||
DISABLE_AI = os.environ.get("DISABLE_AI").lower() in ['yes', '1', 'true']
|
||||
|
||||
PLATFORM = os.environ.get("PLATFORM", "raspberry")
|
||||
|
18
src/utils/platform.py
Normal file
18
src/utils/platform.py
Normal file
@ -0,0 +1,18 @@
|
||||
import config
|
||||
|
||||
if config.PLATFORM == 'raspberry':
|
||||
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \
|
||||
BirbnetesIoTPlatformPlaybackDriver
|
||||
|
||||
elif config.PLATFORM == 'emulator':
|
||||
from birbnetes_iot_platform_emulator import BirbnetesIoTPlatformStatusDriver, BirbnetesIoTPlatformRecordDriver, \
|
||||
BirbnetesIoTPlatformPlaybackDriver
|
||||
|
||||
else:
|
||||
raise ModuleNotFoundError(f"Could not load platform driver for {config.PLATFORM}")
|
||||
|
||||
__all__ = [
|
||||
'BirbnetesIoTPlatformStatusDriver',
|
||||
'BirbnetesIoTPlatformRecordDriver',
|
||||
'BirbnetesIoTPlatformPlaybackDriver'
|
||||
]
|
Loading…
Reference in New Issue
Block a user