[U-Boot] [PATCH 6/7] tools/genboardscfg.py: check if the boards.cfg is up to date
Simon Glass
sjg at chromium.org
Sat Aug 23 03:54:39 CEST 2014
Hi Masahiro,
On 20 August 2014 22:02, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> Hi Simon,
>
>
>
> On Wed, 20 Aug 2014 13:13:13 -0600
> Simon Glass <sjg at chromium.org> wrote:
>> > +def output_is_new():
>> > + """Check if the boards.cfg file is up to date.
>> > +
>> > + Returns:
>> > + True if the boards.cfg file exists and is newer than any of
>> > + *_defconfig, MAINTAINERS and Kconfig*. False otherwise.
>> > + """
>> > + try:
>> > + ctime = os.path.getctime(BOARD_FILE)
>> > + except OSError, exception:
>> > + if exception.errno == errno.ENOENT:
>> > + # return False on 'No such file or directory' error
>> > + return False
>> > + else:
>> > + raise
>>
>> if not os.path.exists(BOARD_FILE)
>> return False
>>
>> would probably be enough.
>>
>
>
> Actually my first code was as follows:
>
> ------------>8------------------------
> if not os.path.exists(BOARD_FILE)
> return False
>
> ctime = os.path.getctime(BOARD_FILE)
> -------------8<----------------------
>
>
>
> But what if someone deletes BOARD_FILE
> between os.path.exists(BOARD_FILE) and os.path.getctime(BOARD_FILE)?
>
> I know it is ridiculous to consider such a rare case.
>
>
> But I believe it is Python style to follow
> "try something and then handle an exception" thing.
>
> I am trying to be a bit strict to this rule
> when invoking OS system calls where there is possibility of failure.
Failure in this case seems safe IMO :-) Anyway I will leave this up to
you, it is not important.
Regards,
Simon
More information about the U-Boot
mailing list