fgebhart / smart_alarm

IoT Open Source Alarm Clock
Apache License 2.0
16 stars 4 forks source link

ImportError: No module named colorschemes #12

Open mathisoneric opened 6 years ago

mathisoneric commented 6 years ago

https://github.com/fgebhart/smart_alarm/blob/44e684cc3541109a76f7a6986a2c6938234dfa3a/smart_alarm/smart_alarm#L69

Bug:

Traceback (most recent call last):
  File "/home/pi/smart_alarm/smart_alarm/smart_alarm", line 69, in <module>
    from modules.led import LEDs
  File "/home/pi/smart_alarm/smart_alarm/modules/led.py", line 5, in <module>
    import colorschemes
ImportError: No module named colorschemes

Issue:

I don't have LEDs installed on my alarm clock. But, your code still tries loading the LED module anyways:

from modules.led import LEDs

The issue is that the LED module then tries loading another module named colorschemes, which I don't have.

Fix:

You should conditionally import the LEDs module with something like:

if os.path.isfile('/home/pi/APA102_Pi/colorschemes.py'):
    from modules.led import LEDs