Skip to content

Commit

Permalink
Hidden RC for turn-off-hat-leds service, fire and forget unit
Browse files Browse the repository at this point in the history
Instead of reporting a non-zero return code back to systemd, always
report zero and do not show systemd failure messages to the user at
bootup. If there is a tbk raised, it is logged to the journal via
a simple print. For context, this script seemed to fail when there
is low-voltage on the Pi, i.e. CKC + battery.
  • Loading branch information
Radu authored and radujipa committed Oct 2, 2017
1 parent ba5a311 commit e60116d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
21 changes: 11 additions & 10 deletions bin/turn-off-hat-leds
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@


import sys
import traceback


COLOUR_BLACK = (0, 0, 0)

RC_SUCCESSFUL = 0
RC_UNEXPECTED_ERROR = 1


def turn_off_pihat():
try:
Expand All @@ -30,9 +28,10 @@ def turn_off_pihat():
return

pi_hat.set_all_leds([COLOUR_BLACK] * pi_hat.LED_COUNT)
return True

except:
return RC_UNEXPECTED_ERROR
print traceback.print_exc()


def turn_off_speaker_led():
Expand All @@ -53,16 +52,18 @@ def turn_off_speaker_led():
if not successful:
return

return True

except:
return RC_UNEXPECTED_ERROR
print traceback.print_exc()


def main():
pihat_rc = turn_off_pihat()
speakerled_rc = turn_off_speaker_led()

return pihat_rc or speakerled_rc
# Call all methods until one succeeds.
turn_off_pihat() or turn_off_speaker_led()


if __name__ == '__main__':
sys.exit(main() or RC_SUCCESSFUL)
# Do not report to systemd that there was an issue, log it instead.
# This is to "avoid showing unuseful messages to users".
sys.exit(main() or 0)
3 changes: 2 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
kano-peripherals (3.13.0-0) unstable; urgency=low

* Added functionality to detect CKCs, CKC v1, CKC v1.1
* Hidden RC from turn-off-hat-leds service, fire and forget

-- Team Kano <dev@kano.me> Wed, 20 Sep 2017 18:29:45 +0100
-- Team Kano <dev@kano.me> Fri, 28 Sep 2017 18:36:45 +0100

kano-peripherals (3.11.0-0) unstable; urgency=low

Expand Down

0 comments on commit e60116d

Please sign in to comment.