[U-Boot] [PATCH] patman: Don't run patman when it is imported as a module
Chris Packham
judge.packham at gmail.com
Fri Jul 31 07:34:23 CEST 2015
Hi Simon,
On Fri, Jul 31, 2015 at 7:47 AM, Simon Glass <sjg at chromium.org> wrote:
> Commit 488d19c (patman: add distutils based installer) has the side effect
> of making patman run twice with each invocation. Fix this by checking for
> 'main program' invocation in patman.py. This is good practice in any case.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
Reviewed-by: Chris Packham <judge.packham at gmail.com>
I did (kind of) think about that at the time when I had to handle the
in-tree vs out-of-tree usage. One solution would have been to move
most of the code to a module ("patch-manager" say) and have the patman
script import that. The same would work for anything else that wanted
to bring in bits of patman (buildman perhaps?).
>
> tools/patman/patman.py | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/patman/patman.py b/tools/patman/patman.py
> index e76fc42..6fe8fe0 100755
> --- a/tools/patman/patman.py
> +++ b/tools/patman/patman.py
> @@ -74,8 +74,11 @@ specified by tags you place in the commits. Use -n to do a dry run first."""
> settings.Setup(parser, options.project, '')
> (options, args) = parser.parse_args()
>
> +if __name__ != "__main__":
> + pass
> +
> # Run our meagre tests
> -if options.test:
> +elif options.test:
> import doctest
>
> sys.argv = [sys.argv[0]]
> --
> 2.5.0.rc2.392.g76e840b
>
More information about the U-Boot
mailing list