micropython-samples/buildcheck/buildcheck.py

13 wiersze
464 B
Python

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