pimoroni / automation-hat

Python library and examples for the Pimoroni Automation HAT, pHAT and HAT Mini
https://shop.pimoroni.com/products/automation-hat
MIT License
121 stars 42 forks source link

try/except clause on imports + __version__ in lib #6

Closed RogueM closed 7 years ago

RogueM commented 7 years ago

this one probably needs a bit of scrutiny before packaging and pushing, just to be sure, since the changes are more than cosmetic.

RogueM commented 7 years ago

right, I see that those were some recent changes for Automation pHAT support. Makes sense, but best to stick to import at front of file, just one of those things that ease up QA.

RogueM commented 7 years ago

I have restored pHAT support, but moved imports at front of file for clarity, with try/except clause to booth... hopefully I haven't screwed up anything?

Gadgetoid commented 7 years ago

Looks like it works, with the exception of the AttributeError which needed to be a NameError to catch the non-existence of sn3218 rather than the lack of attribute i2c: https://github.com/pimoroni/automation-hat/commit/f13f2b1f7122d8e7d389e06c79f215a4c670fff2

RogueM commented 7 years ago

oh? Got an AttributeError when I tried, that's strange.

RogueM commented 7 years ago

aaah, yes, that was when I had sn3218=None outside the catch!