[PATCH 4/4] Add print statement similar to the original mkimage.

Gedare Bloom gedare at rtems.org
Thu Mar 5 02:43:12 UTC 2020


Reviewing on my phone: I see added blank lines, try to avoid unnecessary
whitespace/format changes with functional changes in same commit. Although
we haven't settled in a style, none of the proposed ones use more than 2
blank lines between global definitions.

On Wed, Mar 4, 2020, 4:10 PM Amar Takhar <amar at rtems.org> wrote:

> This is limited to Python 2.6+
> ---
>  misc/tools/mkimage.py | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/misc/tools/mkimage.py b/misc/tools/mkimage.py
> index 38ed11e..fd75f0a 100755
> --- a/misc/tools/mkimage.py
> +++ b/misc/tools/mkimage.py
> @@ -27,6 +27,8 @@
>  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> THE
>  # POSSIBILITY OF SUCH DAMAGE.
>
> +# We support Python 2.6+ so this is okay.
> +from __future__ import print_function
>
>  import argparse
>  from struct import *
> @@ -35,6 +37,8 @@ import os.path
>  import time
>  import binascii
>
> +
> +
>  MAGIC = 0x27051956
>  IMG_NAME_LENGTH = 32
>
> @@ -125,14 +129,16 @@ while True:
>
>  inputcrc = inputcrc & 0xffffffff
>
> -structdata = struct.pack(MAGIC, 0, int(time.time()), inputsize,
> +timestamp = int(time.time())
> +
> +structdata = struct.pack(MAGIC, 0, timestamp, inputsize,
>                  int(options.addr,16), int(options.ep,16), inputcrc,
>                  oss[options.os], archs[options.arch], types[options.type],
>                  comps[options.comp], options.name.encode("utf-8"))
>
>  headercrc = binascii.crc32(structdata) & 0xFFFFFFFF
>
> -structdata =  struct.pack(MAGIC, headercrc, int(time.time()), inputsize,
> +structdata =  struct.pack(MAGIC, headercrc, timestamp, inputsize,
>                  int(options.addr,16), int(options.ep,16), inputcrc,
>                  oss[options.os], archs[options.arch], types[options.type],
>                  comps[options.comp], options.name.encode("utf-8"))
> @@ -141,3 +147,10 @@ outputfile.seek(0)
>  outputfile.write(structdata)
>  outputfile.close()
>  inputfile.close()
> +
> +print("Image Name:   ", options.name)
> +print("Created:      ", time.ctime(timestamp))
> +print("Image Type:   ", options.comp)
> +print("Data Size:    ", inputsize)
> +print("Load Address: ", options.addr)
> +print("Entry Point:  ", options.ep)
> --
> 2.25.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200304/60025ebd/attachment-0001.html>


More information about the devel mailing list