[PATCH] sb: Fix the imports on Python2

Gedare Bloom gedare at rtems.org
Thu Aug 27 15:41:33 UTC 2020


On Wed, Aug 26, 2020 at 11:54 PM <chrisj at rtems.org> wrote:
>
> From: Chris Johns <chrisj at rtems.org>
>
> Closes #4037
> ---
>  source-builder/sb-check         |  2 --
>  source-builder/sb/__init__.py   | 20 ++++++++++++++++++++
>  source-builder/sb/build.py      |  3 +--
>  source-builder/sb/config.py     |  3 +--
>  source-builder/sb/getsources.py |  3 +--
>  source-builder/sb/linux.py      |  2 +-
>  source-builder/sb/reports.py    |  9 +++------
>  source-builder/sb/setbuilder.py |  3 +--
>  source-builder/sb/shell.py      |  3 +--
>  source-builder/sb/simhost.py    |  3 +--
>  source-builder/sb/track.py      |  3 +--
>  11 files changed, 31 insertions(+), 23 deletions(-)
>  create mode 100644 source-builder/sb/__init__.py
>
> diff --git a/source-builder/sb-check b/source-builder/sb-check
> index b75767e..8c60bf6 100755
> --- a/source-builder/sb-check
> +++ b/source-builder/sb-check
> @@ -20,8 +20,6 @@
>
>  from __future__ import print_function
>
> -import sb.check
> -
>  try:
>      import sb.check
>      sb.check.run()
> diff --git a/source-builder/sb/__init__.py b/source-builder/sb/__init__.py
> new file mode 100644
> index 0000000..c4275e2
> --- /dev/null
> +++ b/source-builder/sb/__init__.py
> @@ -0,0 +1,20 @@
> +#
> +# RTEMS Tools Project (http://www.rtems.org/)
> +# Copyright 2020 Chris Johns (chrisj at rtems.org)
> +# All rights reserved.
> +#
> +# This file is part of the RTEMS Tools package in 'rtems-tools'.
> +#
> +# Permission to use, copy, modify, and/or distribute this software for any
> +# purpose with or without fee is hereby granted, provided that the above
> +# copyright notice and this permission notice appear in all copies.
> +#
> +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +
This doesn't follow the template. I guess probably it uses what is in
other rtems-tools files though.
https://docs.rtems.org/branches/master/eng/coding-file-hdr.html#python-file-template

This is MIT license?

> +from __future__ import print_function
> diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
> index f3253dd..16a495b 100644
> --- a/source-builder/sb/build.py
> +++ b/source-builder/sb/build.py
> @@ -48,8 +48,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated')
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error')
> -    sys.exit(1)
> +    raise
>
>  def humanize_number(num, suffix):
>      for unit in ['','K','M','G','T','P','E','Z']:
> diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
> index db795b3..cd0bf94 100644
> --- a/source-builder/sb/config.py
> +++ b/source-builder/sb/config.py
> @@ -45,8 +45,7 @@ except KeyboardInterrupt:
>      print('user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  def _check_bool(value):
>      istrue = None
> diff --git a/source-builder/sb/getsources.py b/source-builder/sb/getsources.py
> index 0ccf257..d348da4 100644
> --- a/source-builder/sb/getsources.py
> +++ b/source-builder/sb/getsources.py
> @@ -40,8 +40,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  def run(args = sys.argv):
>      ec = 0
> diff --git a/source-builder/sb/linux.py b/source-builder/sb/linux.py
> index d773818..d89377b 100644
> --- a/source-builder/sb/linux.py
> +++ b/source-builder/sb/linux.py
> @@ -23,10 +23,10 @@
>  #
>
>  import multiprocessing
> +import platform
>  import pprint
>  import os
>
> -from . import platform
>  from . import path
>
>  def load():
> diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py
> index 34474f3..a20b29e 100644
> --- a/source-builder/sb/reports.py
> +++ b/source-builder/sb/reports.py
> @@ -30,9 +30,6 @@ import datetime
>  import os
>  import sys
>
> -import pprint
> -pp = pprint.PrettyPrinter(indent = 2)
> -
>  try:
>      from . import build
>      from . import check
> @@ -42,15 +39,13 @@ try:
>      from . import log
>      from . import options
>      from . import path
> -    from . import setbuilder
>      from . import sources
>      from . import version
>  except KeyboardInterrupt:
>      print('user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  _line_len = 78
>
> @@ -865,6 +860,7 @@ class report:
>                  raise error.general('writing output file: %s: %s' % (name, err))
>
>      def generate(self, name, tree = None, opts = None, macros = None):
> +        from . import setbuilder
>          self.buildset_start(name)
>          if tree is None:
>              tree = self.tree
> @@ -899,6 +895,7 @@ class report:
>
>  def run(args):
>      try:
> +        from . import setbuilder
>          optargs = { '--list-bsets':   'List available build sets',
>                      '--list-configs': 'List available configurations',
>                      '--format':       'Output format (text, html, markdown, ini, xml)',
> diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
> index 02901d4..b0e2b23 100644
> --- a/source-builder/sb/setbuilder.py
> +++ b/source-builder/sb/setbuilder.py
> @@ -48,8 +48,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  def macro_expand(macros, _str):
>      cstr = None
> diff --git a/source-builder/sb/shell.py b/source-builder/sb/shell.py
> index f1e669a..ecb8188 100644
> --- a/source-builder/sb/shell.py
> +++ b/source-builder/sb/shell.py
> @@ -33,8 +33,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  def expand(macros, line):
>      #
> diff --git a/source-builder/sb/simhost.py b/source-builder/sb/simhost.py
> index e3f759b..1ff98e8 100644
> --- a/source-builder/sb/simhost.py
> +++ b/source-builder/sb/simhost.py
> @@ -42,8 +42,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  #
>  # Define host profiles so it can simulated on another host.
> diff --git a/source-builder/sb/track.py b/source-builder/sb/track.py
> index 49344fe..cf33a00 100644
> --- a/source-builder/sb/track.py
> +++ b/source-builder/sb/track.py
> @@ -41,8 +41,7 @@ except KeyboardInterrupt:
>      print('abort: user terminated', file = sys.stderr)
>      sys.exit(1)
>  except:
> -    print('error: unknown application load error', file = sys.stderr)
> -    sys.exit(1)
> +    raise
>
>  def unique(l):
>      return sorted(list(set(l)))
> --
> 2.17.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list