Changeset 9c7be8b in rtems-tools


Ignore:
Timestamp:
Mar 4, 2020, 9:04:27 PM (4 months ago)
Author:
Amar Takhar <amar@…>
Branches:
5, master
Children:
2444acb
Parents:
e29d0a6
git-author:
Amar Takhar <amar@…> (03/04/20 21:04:27)
git-committer:
Amar Takhar <verm@…> (03/04/20 23:07:41)
Message:

Fix to work under Pyhon 2 and Python 3.

Also changed 'python2' to 'python' in the shebang.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/mkimage.py

    re29d0a6 r9c7be8b  
    1 #!/usr/bin/env python2
     1#!/usr/bin/env python
    22
    33# A quickly bashed together replacement for u-boot's mkimage written in python
     
    8282
    8383if options.arch not in archs:
    84         print "Invalid architecture specified, aborting"
     84        print("Invalid architecture specified, aborting")
    8585        sys.exit(2)
    8686
    8787if options.os not in oss:
    88         print "Invalid operating system specified, aborting"
     88        print("Invalid operating system specified, aborting")
    8989        sys.exit(2)
    9090
    9191if options.comp not in comps:
    92         print "Invalid compression specified, aborting"
     92        print("Invalid compression specified, aborting")
    9393        sys.exit(2)
    9494
    9595if options.type not in types:
    96         print "Invalid image type specified, aborting"
     96        print("Invalid image type specified, aborting")
    9797        sys.exit(2)
    9898
     
    102102
    103103except OSError as e:
    104         print "Invalid datafile specified, aborting: %s" % e
     104        print("Invalid datafile specified, aborting: %s" % e)
    105105        sys.exit(2)
    106106
     
    109109
    110110except IOError as e:
    111         print "Error opening output file for writing, aborting: %s" % e
     111        print("Error opening output file for writing, aborting: %s" % e)
    112112        sys.exit(1)
    113113
     
    129129                int(options.addr,16), int(options.ep,16), inputcrc,
    130130                oss[options.os], archs[options.arch], types[options.type],
    131                 comps[options.comp], options.name)
     131                comps[options.comp], options.name.encode("utf-8"))
    132132
    133133headercrc = binascii.crc32(structdata) & 0xFFFFFFFF
     
    136136                int(options.addr,16), int(options.ep,16), inputcrc,
    137137                oss[options.os], archs[options.arch], types[options.type],
    138                 comps[options.comp], options.name)
     138                comps[options.comp], options.name.encode("utf-8"))
    139139
    140140outputfile.seek(0)
Note: See TracChangeset for help on using the changeset viewer.