From 6d95edc9bcf9660f6dde4088c561b7845be01cba Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Sat, 26 Dec 2015 06:57:32 +0000 Subject: [PATCH] Build check added --- README.md | 6 ++++++ buildcheck/buildcheck.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 buildcheck/buildcheck.py diff --git a/README.md b/README.md index dadc4b1..55cb3fd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ A place for assorted code ideas for MicroPython. mutex: A class providing mutal exclusion enabling interrupt handlers and the main program to access shared data in a manner which ensures data integrity. +watchdog: How to access the simpler of the Pyboard's watchdog timers. + +radio: A trivial class simplifying the use of the nRF24L01 radio for the case where a wireless +link between two devices is required. + +Buildcheck: Raise an exception if a firmware build is earlier than a given date. Any code placed here is released under the MIT License (MIT). The MIT License (MIT) diff --git a/buildcheck/buildcheck.py b/buildcheck/buildcheck.py new file mode 100644 index 0000000..28c5630 --- /dev/null +++ b/buildcheck/buildcheck.py @@ -0,0 +1,12 @@ +# Raise an exception if a firmware build is earlier than a given date +# buildcheck((2015,10,9)) +def buildcheck(tupTarget): + fail = True + if 'uname' in dir(os): + datestring = os.uname()[3] + date = datestring.split(' on')[1] + idate = tuple([int(x) for x in date.split('-')]) + fail = idate < tupTarget + if fail: + raise OSError('This driver requires a firmware build dated {:4d}-{:02d}-{:02d} or later'.format(*tupTarget)) +