Build check added

pull/7/head
Peter Hinch 2015-12-26 06:57:32 +00:00
rodzic 864dee7758
commit 6d95edc9bc
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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))