Changeset 28f4adb in mainline


Ignore:
Timestamp:
2010-11-02T11:13:36Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4687a26c, e06ef614
Parents:
458619f7
git-author:
Vojtech Horky <> (2010-11-02 11:13:36)
git-committer:
Martin Decky <martin@…> (2010-11-02 11:13:36)
Message:

update scripts for compatibility with Python 3 (thx Vojtech Horky and Martin Sucha)

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • contrib/arch/hadlbppp.py

    r458619f7 r28f4adb  
    4242        "Print usage syntax"
    4343       
    44         print "%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname
    45         print
    46         print "--bp   Dump original Behavior Protocols (dChecker, BPSlicer)"
    47         print "--ebp  Dump Extended Behavior Protocols (bp2promela)"
    48         print "--adl  Dump Architecture Description Language (modified SOFA ADL/CDL)"
    49         print "--dot  Dump Dot architecture diagram (GraphViz)"
    50         print "--nop  Do not dump anything (just input files syntax check)"
    51         print
     44        print("%s <--bp|--ebp|--adl|--dot|--nop>+ <OUTPUT>" % prname)
     45        print()
     46        print("--bp   Dump original Behavior Protocols (dChecker, BPSlicer)")
     47        print("--ebp  Dump Extended Behavior Protocols (bp2promela)")
     48        print("--adl  Dump Architecture Description Language (modified SOFA ADL/CDL)")
     49        print("--dot  Dump Dot architecture diagram (GraphViz)")
     50        print("--nop  Do not dump anything (just input files syntax check)")
     51        print()
    5252
    5353def tabs(cnt):
     
    163163                                                result.append(tokens[i])
    164164                                else:
    165                                         print "%s: Syntax error in tentative statement" % name
     165                                        print("%s: Syntax error in tentative statement" % name)
    166166                        else:
    167                                 print "%s: Expected '{' for tentative statement" % name
     167                                print("%s: Expected '{' for tentative statement" % name)
    168168                else:
    169169                        result.append(tokens[i])
     
    231231                                                                result.append(tokens[i])
    232232                                                else:
    233                                                         print "%s: Syntax error in alternative statement" % name
     233                                                        print("%s: Syntax error in alternative statement" % name)
    234234                                        else:
    235                                                 print "%s: Expected '{' for alternative statement body" % name
     235                                                print("%s: Expected '{' for alternative statement body" % name)
    236236                                else:
    237                                         print "%s: At least one pattern and one replacement required for alternative statement" % name
     237                                        print("%s: At least one pattern and one replacement required for alternative statement" % name)
    238238                        else:
    239                                 print "%s: Expected '(' for alternative statement head" % name
     239                                print("%s: Expected '(' for alternative statement head" % name)
    240240                else:
    241241                        result.append(tokens[i])
     
    269269                                        result.append(tokens[i])
    270270                        else:
    271                                 print "%s: Unexpected end of protocol" % name
     271                                print("%s: Unexpected end of protocol" % name)
    272272               
    273273                i += 1
     
    349349                elif (token == ")"):
    350350                        if (indent < base_indent):
    351                                 print "%s: Too many parentheses" % name
     351                                print("%s: Too many parentheses" % name)
    352352                       
    353353                        indent -= 1
     
    358358                elif (token == "}"):
    359359                        if (indent < base_indent):
    360                                 print "%s: Too many parentheses" % name
     360                                print("%s: Too many parentheses" % name)
    361361                       
    362362                        indent -= 1
     
    370370       
    371371        if (indent > base_indent):
    372                 print "%s: Missing parentheses" % name
     372                print("%s: Missing parentheses" % name)
    373373       
    374374        output = output.strip()
     
    405405                        result.extend(inherited_protocols(supiface))
    406406                else:
    407                         print "%s: Extends unknown interface '%s'" % (iface['name'], iface['extends'])
     407                        print("%s: Extends unknown interface '%s'" % (iface['name'], iface['extends']))
    408408       
    409409        return result
     
    459459                                                protocols.append(proto)
    460460                        else:
    461                                 print "%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface'])
     461                                print("%s: Provided interface '%s' is undefined" % (frame['name'], provides['iface']))
    462462       
    463463        if (opt_bp):
    464                 outf = file(outname, "w")
     464                outf = open(outname, "w")
    465465                outf.write(parse_bp(outname, merge_bp(initialization, finalization, protocols), 0))
    466466                outf.close()
    467467       
    468468        if (opt_ebp):
    469                 outf = file(outname, "w")
     469                outf = open(outname, "w")
    470470                outf.write(parse_ebp(frame['name'], outname, merge_bp(initialization, finalization, protocols), 0))
    471471                outf.close()
     
    514514       
    515515        if (opt_bp):
    516                 outf = file(outname, "w")
     516                outf = open(outname, "w")
    517517                outf.write("NULL")
    518518                outf.close()
    519519       
    520520        if (opt_ebp):
    521                 outf = file(outname, "w")
     521                outf = open(outname, "w")
    522522                outf.write("component null {\n\tbehavior {\n\t\tNULL\n\t}\n}")
    523523                outf.close()
     
    587587                                        insts.append({'var': "%s_%s" % (prefix, inst['var']), 'frame': subframe})
    588588                                else:
    589                                         print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
     589                                        print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']))
    590590       
    591591        if ('bind' in arch):
     
    612612       
    613613        if (arch is None):
    614                 print "Unable to find system architecture"
     614                print("Unable to find system architecture")
    615615                return
    616616       
     
    634634                                        insts.append({'var': inst['var'], 'frame': subframe})
    635635                                else:
    636                                         print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
     636                                        print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']))
    637637       
    638638        if ('bind' in arch):
     
    642642        if ('delegate' in arch):
    643643                for delegate in arch['delegate']:
    644                         print "Unable to delegate interface in system architecture"
     644                        print("Unable to delegate interface in system architecture")
    645645                        break
    646646       
    647647        if ('subsume' in arch):
    648648                for subsume in arch['subsume']:
    649                         print "Unable to subsume interface in system architecture"
     649                        print("Unable to subsume interface in system architecture")
    650650                        break
    651651       
     
    654654        outname = os.path.join(outdir, "%s.archbp" % arch['name'])
    655655        if ((opt_bp) or (opt_ebp)):
    656                 outf = file(outname, "w")
     656                outf = open(outname, "w")
    657657        else:
    658658                outf = None
     
    709709               
    710710                if (not os.path.isfile(path)):
    711                         print "%s: Unable to include file %s" % (inname, path)
     711                        print("%s: Unable to include file %s" % (inname, path))
    712712                        return ""
    713713        else:
     
    716716                nested_root = root
    717717       
    718         inf = file(path, "r")
     718        inf = open(path, "r")
    719719       
    720720        raw = preproc_adl(inf.read(), inarg)
     
    733733                if (POST_INC in context):
    734734                        if (token != "]"):
    735                                 print "%s: Expected ]" % inname
     735                                print("%s: Expected ]" % inname)
    736736                       
    737737                        context.remove(POST_INC)
     
    774774                        if (NULL in context):
    775775                                if (token != ";"):
    776                                         print "%s: Expected ';' in frame '%s'" % (inname, frame)
     776                                        print("%s: Expected ';' in frame '%s'" % (inname, frame))
    777777                                else:
    778778                                        output += "%s\n" % token
     
    798798                                               
    799799                                                if ('finalization' in frame_properties[frame]):
    800                                                         print "%s: Finalization protocol for frame '%s' already defined" % (inname, frame)
     800                                                        print("%s: Finalization protocol for frame '%s' already defined" % (inname, frame))
    801801                                                else:
    802802                                                        frame_properties[frame]['finalization'] = bp
     
    832832                                               
    833833                                                if ('initialization' in frame_properties[frame]):
    834                                                         print "%s: Initialization protocol for frame '%s' already defined" % (inname, frame)
     834                                                        print("%s: Initialization protocol for frame '%s' already defined" % (inname, frame))
    835835                                                else:
    836836                                                        frame_properties[frame]['initialization'] = bp
     
    866866                                               
    867867                                                if ('protocol' in frame_properties[frame]):
    868                                                         print "%s: Protocol for frame '%s' already defined" % (inname, frame)
     868                                                        print("%s: Protocol for frame '%s' already defined" % (inname, frame))
    869869                                                else:
    870870                                                        frame_properties[frame]['protocol'] = bp
     
    889889                                        if (FIN in context):
    890890                                                if (token != ";"):
    891                                                         print "%s: Expected ';' in frame '%s'" % (inname, frame)
     891                                                        print("%s: Expected ';' in frame '%s'" % (inname, frame))
    892892                                                else:
    893893                                                        output += "%s" % token
     
    898898                                        if (VAR in context):
    899899                                                if (not identifier(token)):
    900                                                         print "%s: Variable name expected in frame '%s'" % (inname, frame)
     900                                                        print("%s: Variable name expected in frame '%s'" % (inname, frame))
    901901                                                else:
    902902                                                        if (not frame in frame_properties):
     
    919919                                        else:
    920920                                                if (not identifier(token)):
    921                                                         print "%s: Interface name expected in frame '%s'" % (inname, frame)
     921                                                        print("%s: Interface name expected in frame '%s'" % (inname, frame))
    922922                                                else:
    923923                                                        arg0 = token
     
    930930                                        if (FIN in context):
    931931                                                if (token != ";"):
    932                                                         print "%s: Expected ';' in frame '%s'" % (inname, frame)
     932                                                        print("%s: Expected ';' in frame '%s'" % (inname, frame))
    933933                                                else:
    934934                                                        output += "%s" % token
     
    939939                                        if (VAR in context):
    940940                                                if (not identifier(token)):
    941                                                         print "%s: Variable name expected in frame '%s'" % (inname, frame)
     941                                                        print("%s: Variable name expected in frame '%s'" % (inname, frame))
    942942                                                else:
    943943                                                        if (not frame in frame_properties):
     
    960960                                        else:
    961961                                                if (not identifier(token)):
    962                                                         print "%s: Interface name expected in frame '%s'" % (inname, frame)
     962                                                        print("%s: Interface name expected in frame '%s'" % (inname, frame))
    963963                                                else:
    964964                                                        arg0 = token
     
    970970                                if (token == "}"):
    971971                                        if (indent != 2):
    972                                                 print "%s: Wrong number of parentheses in frame '%s'" % (inname, frame)
     972                                                print("%s: Wrong number of parentheses in frame '%s'" % (inname, frame))
    973973                                        else:
    974974                                                indent = 0
     
    10101010                                        continue
    10111011                               
    1012                                 print "%s: Unknown token '%s' in frame '%s'" % (inname, token, frame)
     1012                                print("%s: Unknown token '%s' in frame '%s'" % (inname, token, frame))
    10131013                                continue
    10141014                       
     
    10271027                                        continue
    10281028                               
    1029                                 print "%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame)
     1029                                print("%s: Unknown token '%s' in frame head '%s'" % (inname, token, frame))
    10301030                               
    10311031                                continue
    10321032                       
    10331033                        if (not identifier(token)):
    1034                                 print "%s: Expected frame name" % inname
     1034                                print("%s: Expected frame name" % inname)
    10351035                        else:
    10361036                                frame = token
     
    10501050                        if (NULL in context):
    10511051                                if (token != ";"):
    1052                                         print "%s: Expected ';' in interface '%s'" % (inname, interface)
     1052                                        print("%s: Expected ';' in interface '%s'" % (inname, interface))
    10531053                                else:
    10541054                                        output += "%s\n" % token
     
    10741074                                               
    10751075                                                if ('protocol' in iface_properties[interface]):
    1076                                                         print "%s: Protocol for interface '%s' already defined" % (inname, interface)
     1076                                                        print("%s: Protocol for interface '%s' already defined" % (inname, interface))
    10771077                                                else:
    10781078                                                        iface_properties[interface]['protocol'] = bp
     
    10941094                                        if (FIN in context):
    10951095                                                if (token != ";"):
    1096                                                         print "%s: Expected ';' in interface '%s'" % (inname, interface)
     1096                                                        print("%s: Expected ';' in interface '%s'" % (inname, interface))
    10971097                                                else:
    10981098                                                        output += "%s" % token
     
    11241124                                        if (PAR_LEFT in context):
    11251125                                                if (token != "("):
    1126                                                         print "%s: Expected '(' in interface '%s'" % (inname, interface)
     1126                                                        print("%s: Expected '(' in interface '%s'" % (inname, interface))
    11271127                                                else:
    11281128                                                        output += "%s" % token
     
    11331133                                       
    11341134                                        if (not identifier(token)):
    1135                                                 print "%s: Method identifier expected in interface '%s'" % (inname, interface)
     1135                                                print("%s: Method identifier expected in interface '%s'" % (inname, interface))
    11361136                                        else:
    11371137                                                output += "%s" % token
     
    11421142                                if (token == "}"):
    11431143                                        if (indent != 2):
    1144                                                 print "%s: Wrong number of parentheses in interface '%s'" % (inname, interface)
     1144                                                print("%s: Wrong number of parentheses in interface '%s'" % (inname, interface))
    11451145                                        else:
    11461146                                                indent = 0
     
    11631163                                        continue
    11641164                               
    1165                                 print "%s: Unknown token '%s' in interface '%s'" % (inname, token, interface)
     1165                                print("%s: Unknown token '%s' in interface '%s'" % (inname, token, interface))
    11661166                                continue
    11671167                       
     
    11831183                                                continue
    11841184                                               
    1185                                         print "%s: Expected '{' or ';' in interface head '%s'" % (inname, interface)
     1185                                        print("%s: Expected '{' or ';' in interface head '%s'" % (inname, interface))
    11861186                                        continue
    11871187                               
    11881188                                if (EXTENDS in context):
    11891189                                        if (not identifier(token)):
    1190                                                 print "%s: Expected inherited interface name in interface head '%s'" % (inname, interface)
     1190                                                print("%s: Expected inherited interface name in interface head '%s'" % (inname, interface))
    11911191                                        else:
    11921192                                                output += "%s " % token
     
    12181218                                        continue
    12191219                               
    1220                                 print "%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface)
     1220                                print("%s: Expected 'extends', '{' or ';' in interface head '%s'" % (inname, interface))
    12211221                                continue
    12221222                       
    12231223                        if (not identifier(token)):
    1224                                 print "%s: Expected interface name" % inname
     1224                                print("%s: Expected interface name" % inname)
    12251225                        else:
    12261226                                interface = token
     
    12401240                        if (NULL in context):
    12411241                                if (token != ";"):
    1242                                         print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
     1242                                        print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
    12431243                                else:
    12441244                                        output += "%s\n" % token
     
    12541254                                        if (FIN in context):
    12551255                                                if (token != ";"):
    1256                                                         print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
     1256                                                        print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
    12571257                                                else:
    12581258                                                        output += "%s" % token
     
    12641264                                        if (VAR in context):
    12651265                                                if (not descriptor(token)):
    1266                                                         print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
     1266                                                        print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture))
    12671267                                                else:
    12681268                                                        if (not architecture in arch_properties):
     
    12831283                                        if (TO in context):
    12841284                                                if (token != "to"):
    1285                                                         print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
     1285                                                        print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
    12861286                                                else:
    12871287                                                        output += "%s " % token
     
    12921292                                       
    12931293                                        if (not identifier(token)):
    1294                                                 print "%s: Expected interface name in architecture '%s'" % (inname, architecture)
     1294                                                print("%s: Expected interface name in architecture '%s'" % (inname, architecture))
    12951295                                        else:
    12961296                                                output += "%s " % token
     
    13031303                                        if (FIN in context):
    13041304                                                if (token != ";"):
    1305                                                         print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
     1305                                                        print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
    13061306                                                else:
    13071307                                                        output += "%s" % token
     
    13131313                                        if (VAR in context):
    13141314                                                if (not identifier(token)):
    1315                                                         print "%s: Expected interface name in architecture '%s'" % (inname, architecture)
     1315                                                        print("%s: Expected interface name in architecture '%s'" % (inname, architecture))
    13161316                                                else:
    13171317                                                        if (not architecture in arch_properties):
     
    13321332                                        if (TO in context):
    13331333                                                if (token != "to"):
    1334                                                         print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
     1334                                                        print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
    13351335                                                else:
    13361336                                                        output += "%s " % token
     
    13411341                                       
    13421342                                        if (not descriptor(token)):
    1343                                                 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
     1343                                                print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture))
    13441344                                        else:
    13451345                                                output += "%s " % token
     
    13521352                                        if (FIN in context):
    13531353                                                if (token != ";"):
    1354                                                         print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
     1354                                                        print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
    13551355                                                else:
    13561356                                                        output += "%s" % token
     
    13621362                                        if (VAR in context):
    13631363                                                if (not descriptor(token)):
    1364                                                         print "%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture)
     1364                                                        print("%s: Expected second interface descriptor in architecture '%s'" % (inname, architecture))
    13651365                                                else:
    13661366                                                        if (not architecture in arch_properties):
     
    13811381                                        if (TO in context):
    13821382                                                if (token != "to"):
    1383                                                         print "%s: Expected 'to' in architecture '%s'" % (inname, architecture)
     1383                                                        print("%s: Expected 'to' in architecture '%s'" % (inname, architecture))
    13841384                                                else:
    13851385                                                        output += "%s " % token
     
    13901390                                       
    13911391                                        if (not descriptor(token)):
    1392                                                 print "%s: Expected interface descriptor in architecture '%s'" % (inname, architecture)
     1392                                                print("%s: Expected interface descriptor in architecture '%s'" % (inname, architecture))
    13931393                                        else:
    13941394                                                output += "%s " % token
     
    14011401                                        if (FIN in context):
    14021402                                                if (token != ";"):
    1403                                                         print "%s: Expected ';' in architecture '%s'" % (inname, architecture)
     1403                                                        print("%s: Expected ';' in architecture '%s'" % (inname, architecture))
    14041404                                                else:
    14051405                                                        output += "%s" % token
     
    14111411                                        if (VAR in context):
    14121412                                                if (not identifier(token)):
    1413                                                         print "%s: Expected instance name in architecture '%s'" % (inname, architecture)
     1413                                                        print("%s: Expected instance name in architecture '%s'" % (inname, architecture))
    14141414                                                else:
    14151415                                                        if (not architecture in arch_properties):
     
    14291429                                       
    14301430                                        if (not identifier(token)):
    1431                                                 print "%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture)
     1431                                                print("%s: Expected frame/architecture type in architecture '%s'" % (inname, architecture))
    14321432                                        else:
    14331433                                                output += "%s " % token
     
    14391439                                if (token == "}"):
    14401440                                        if (indent != 1):
    1441                                                 print "%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture)
     1441                                                print("%s: Wrong number of parentheses in architecture '%s'" % (inname, architecture))
    14421442                                        else:
    14431443                                                indent -= 1
     
    14681468                                        continue
    14691469                               
    1470                                 print "%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture)
     1470                                print("%s: Unknown token '%s' in architecture '%s'" % (inname, token, architecture))
    14711471                                continue
    14721472                       
     
    14871487                               
    14881488                                if (not word(token)):
    1489                                         print "%s: Expected word in architecture head '%s'" % (inname, architecture)
     1489                                        print("%s: Expected word in architecture head '%s'" % (inname, architecture))
    14901490                                else:
    14911491                                        output += "%s " % token
     
    14941494                       
    14951495                        if (not identifier(token)):
    1496                                 print "%s: Expected architecture name" % inname
     1496                                print("%s: Expected architecture name" % inname)
    14971497                        else:
    14981498                                architecture = token
     
    15141514                if (SYSTEM in context):
    15151515                        if (token != "architecture"):
    1516                                 print "%s: Expected 'architecture'" % inname
     1516                                print("%s: Expected 'architecture'" % inname)
    15171517                        else:
    15181518                                output += "%s " % token
     
    15411541                        continue
    15421542               
    1543                 print "%s: Unknown token '%s'" % (inname, token)
     1543                print("%s: Unknown token '%s'" % (inname, token))
    15441544       
    15451545        inf.close()
     
    15751575       
    15761576        if ((output != "") and (opt_adl)):
    1577                 outf = file(outname, "w")
     1577                outf = open(outname, "w")
    15781578                outf.write(output)
    15791579                outf.close()
     
    16331633                                        merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1)
    16341634                                else:
    1635                                         print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
     1635                                        print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']))
    16361636       
    16371637        if ('bind' in arch):
     
    17281728       
    17291729        if (arch is None):
    1730                 print "Unable to find system architecture"
     1730                print("Unable to find system architecture")
    17311731                return
    17321732       
    17331733        if (opt_dot):
    17341734                outname = os.path.join(outdir, "%s.dot" % arch['name'])
    1735                 outf = file(outname, "w")
     1735                outf = open(outname, "w")
    17361736               
    17371737                outf.write("digraph {\n")
     
    17521752                                                merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1)
    17531753                                        else:
    1754                                                 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type'])
     1754                                                print("%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']))
    17551755               
    17561756                if ('bind' in arch):
     
    17841784                if ('delegate' in arch):
    17851785                        for delegate in arch['delegate']:
    1786                                 print "Unable to delegate interface in system architecture"
     1786                                print("Unable to delegate interface in system architecture")
    17871787                                break
    17881788               
    17891789                if ('subsume' in arch):
    17901790                        for subsume in arch['subsume']:
    1791                                 print "Unable to subsume interface in system architecture"
     1791                                print("Unable to subsume interface in system architecture")
    17921792                                break
    17931793               
     
    18261826                        pass
    18271827                else:
    1828                         print "Error: Unknown command line option '%s'" % arg
     1828                        print("Error: Unknown command line option '%s'" % arg)
    18291829                        return
    18301830       
    18311831        if ((opt_bp) and (opt_ebp)):
    1832                 print "Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols"
     1832                print("Error: Cannot dump both original Behavior Protocols and Extended Behavior Protocols")
    18331833                return
    18341834       
    18351835        path = os.path.abspath(sys.argv[-1])
    18361836        if (not os.path.isdir(path)):
    1837                 print "Error: <OUTPUT> is not a directory"
     1837                print("Error: <OUTPUT> is not a directory")
    18381838                return
    18391839       
  • kernel/tools/amd64/decpt.py

    r458619f7 r28f4adb  
    77def main():
    88    if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'):
    9         print "%s 0x..." % sys.argv[0]
     9        print("%s 0x..." % sys.argv[0])
    1010        sys.exit(1)
    1111   
     
    1616    ptl1 = (address >> 30) & 0x1ff
    1717    ptl0 = (address >> 39) & 0x1ff
    18     print "Ptl0:   %3d" % ptl0
    19     print "Ptl1:   %3d" % ptl1
    20     print "Ptl2:   %3d" % ptl2
    21     print "Ptl3:   %3d" % ptl3
    22     print "Offset: 0x%x" % offset
     18    print("Ptl0:   %3d" % ptl0)
     19    print("Ptl1:   %3d" % ptl1)
     20    print("Ptl2:   %3d" % ptl2)
     21    print("Ptl3:   %3d" % ptl3)
     22    print("Offset: 0x%x" % offset)
    2323
    2424if __name__ == '__main__':
  • kernel/tools/genmap.py

    r458619f7 r28f4adb  
    8686        obdump = read_obdump(obmapf)
    8787       
    88         def sorter(x,y):
    89                 return cmp(x[0],y[0])
     88        def key_sorter(x):
     89                return x[0]
    9090       
    9191        for line in kmapf:
     
    9393                res = startfile.match(line)
    9494               
    95                 if ((res) and (obdump[res.group(1)].has_key(res.group(3)))):
     95                if ((res) and (res.group(3) in obdump[res.group(1)])):
    9696                        offset = int(res.group(2), 16)
    9797                        fname = res.group(3)
    9898                        symbols = obdump[res.group(1)][fname]
    99                         symbols.sort(sorter)
     99                        symbols.sort(key = key_sorter)
    100100                        for addr, symbol in symbols:
    101101                                value = fname + ':' + symbol
     
    107107def main():
    108108        if (len(sys.argv) != 4):
    109                 print "Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0]
     109                print("Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0])
    110110                return 1
    111111       
    112112        kmapf = open(sys.argv[1], 'r')
    113113        obmapf = open(sys.argv[2], 'r')
    114         out = open(sys.argv[3], 'w')
     114        out = open(sys.argv[3], 'wb')
    115115       
    116116        generate(kmapf, obmapf, out)
  • kernel/tools/ia32/decpt.py

    r458619f7 r28f4adb  
    77def main():
    88    if len(sys.argv) != 2 or not sys.argv[1].startswith('0x'):
    9         print "%s 0x..." % sys.argv[0]
     9        print("%s 0x..." % sys.argv[0])
    1010        sys.exit(1)
    1111   
     
    1414    ptl1 = (address >> 12) & 0x3ff
    1515    ptl0 = (address >> 22) & 0x3ff
    16     print "Ptl0:   %3d" % ptl0
    17     print "Ptl1:   %3d" % ptl1
    18     print "Offset: 0x%x" % offset
     16    print("Ptl0:   %3d" % ptl0)
     17    print("Ptl1:   %3d" % ptl1)
     18    print("Offset: 0x%x" % offset)
    1919
    2020if __name__ == '__main__':
  • tools/autotool.py

    r458619f7 r28f4adb  
    7575        "Read HelenOS build configuration"
    7676       
    77         inf = file(fname, 'r')
     77        inf = open(fname, 'r')
    7878       
    7979        for line in inf:
     
    191191        check_common(common, "CC")
    192192       
    193         outf = file(PROBE_SOURCE, 'w')
     193        outf = open(PROBE_SOURCE, 'w')
    194194        outf.write(PROBE_HEAD)
    195195       
     
    212212        if (not os.path.isfile(PROBE_OUTPUT)):
    213213                sys.stderr.write("failed\n")
    214                 print output[1]
     214                print(output[1])
    215215                print_error(["Error executing \"%s\"." % " ".join(args),
    216216                             "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
     
    221221        sys.stderr.write("ok\n")
    222222       
    223         inf = file(PROBE_OUTPUT, 'r')
     223        inf = open(PROBE_OUTPUT, 'r')
    224224        lines = inf.readlines()
    225225        inf.close()
     
    343343        "Create makefile output"
    344344       
    345         outmk = file(mkname, 'w')
     345        outmk = open(mkname, 'w')
    346346       
    347347        outmk.write('#########################################\n')
     
    357357        "Create header output"
    358358       
    359         outhd = file(hdname, 'w')
     359        outhd = open(hdname, 'w')
    360360       
    361361        outhd.write('/***************************************\n')
  • tools/checkers/clang.py

    r458619f7 r28f4adb  
    4242def usage(prname):
    4343        "Print usage syntax"
    44         print prname + " <ROOT>"
     44        print(prname + " <ROOT>")
    4545
    4646def clang(root, job):
     
    5050       
    5151        if (not os.path.isfile(inname)):
    52                 print "Unable to open %s" % inname
    53                 print "Did you run \"make precheck\" on the source tree?"
     52                print("Unable to open %s" % inname)
     53                print("Did you run \"make precheck\" on the source tree?")
    5454                return False
    5555       
    56         inf = file(inname, "r")
     56        inf = open(inname, "r")
    5757        records = inf.read().splitlines()
    5858        inf.close()
     
    6464               
    6565                if (len(arg) < 6):
    66                         print "Not enought jobfile record arguments"
     66                        print("Not enought jobfile record arguments")
    6767                        return False
    6868               
     
    7676                srcfqname = os.path.join(base, srcfname)
    7777                if (not os.path.isfile(srcfqname)):
    78                         print "Source %s not found" % srcfqname
     78                        print("Source %s not found" % srcfqname)
    7979                        return False
    8080               
     
    108108       
    109109        if (not os.path.isfile(config)):
    110                 print "%s not found." % config
    111                 print "Please specify the path to HelenOS build tree root as the first argument."
     110                print("%s not found." % config)
     111                print("Please specify the path to HelenOS build tree root as the first argument.")
    112112                return
    113113       
     
    115115                if (not clang(rootdir, job)):
    116116                        print
    117                         print "Failed job: %s" % job
     117                        print("Failed job: %s" % job)
    118118                        return
    119119       
    120120        print
    121         print "All jobs passed"
     121        print("All jobs passed")
    122122
    123123if __name__ == '__main__':
  • tools/checkers/jobfile.py

    r458619f7 r28f4adb  
    5454                                nil = True
    5555                        else:
    56                                 print "Unexpected '%s'" % record[i]
     56                                print("Unexpected '%s'" % record[i])
    5757                                return False
    5858               
  • tools/checkers/stanse.py

    r458619f7 r28f4adb  
    4343def usage(prname):
    4444        "Print usage syntax"
    45         print prname + " <ROOT>"
     45        print(prname + " <ROOT>")
    4646
    4747def stanse(root, job):
     
    5454       
    5555        if (not os.path.isfile(inname)):
    56                 print "Unable to open %s" % inname
    57                 print "Did you run \"make precheck\" on the source tree?"
     56                print("Unable to open %s" % inname)
     57                print("Did you run \"make precheck\" on the source tree?")
    5858                return False
    5959       
    60         inf = file(inname, "r")
     60        inf = open(inname, "r")
    6161        records = inf.read().splitlines()
    6262        inf.close()
     
    6969               
    7070                if (len(arg) < 6):
    71                         print "Not enought jobfile record arguments"
     71                        print("Not enought jobfile record arguments")
    7272                        return False
    7373               
     
    8181                srcfqname = os.path.join(base, srcfname)
    8282                if (not os.path.isfile(srcfqname)):
    83                         print "Source %s not found" % srcfqname
     83                        print("Source %s not found" % srcfqname)
    8484                        return False
    8585               
     
    9090                output.append([srcfname, tgtfname, base, options])
    9191       
    92         outf = file(outname, "w")
     92        outf = open(outname, "w")
    9393        for record in output:
    9494                outf.write("{%s},{%s},{%s},{%s}\n" % (record[0], record[1], record[2], record[3]))
     
    121121       
    122122        if (not os.path.isfile(config)):
    123                 print "%s not found." % config
    124                 print "Please specify the path to HelenOS build tree root as the first argument."
     123                print("%s not found." % config)
     124                print("Please specify the path to HelenOS build tree root as the first argument.")
    125125                return
    126126       
     
    128128                if (not stanse(rootdir, job)):
    129129                        print
    130                         print "Failed job: %s" % job
     130                        print("Failed job: %s" % job)
    131131                        return
    132132       
    133133        print
    134         print "All jobs passed"
     134        print("All jobs passed")
    135135
    136136if __name__ == '__main__':
  • tools/checkers/vcc.py

    r458619f7 r28f4adb  
    4949def usage(prname):
    5050        "Print usage syntax"
    51         print prname + " <ROOT> [VCC_PATH]"
     51        print(prname + " <ROOT> [VCC_PATH]")
    5252
    5353def cygpath(upath):
     
    7272        preproc = subprocess.Popen(args, stdout = subprocess.PIPE).communicate()[0]
    7373       
    74         tmpf = file(tmpfname, "w")
     74        tmpf = open(tmpfname, "w")
    7575        tmpf.write(specification)
    7676       
     
    108108       
    109109        if (not os.path.isfile(inname)):
    110                 print "Unable to open %s" % inname
    111                 print "Did you run \"make precheck\" on the source tree?"
     110                print("Unable to open %s" % inname)
     111                print("Did you run \"make precheck\" on the source tree?")
    112112                return False
    113113       
    114         inf = file(inname, "r")
     114        inf = open(inname, "r")
    115115        records = inf.read().splitlines()
    116116        inf.close()
     
    122122               
    123123                if (len(arg) < 6):
    124                         print "Not enought jobfile record arguments"
     124                        print("Not enought jobfile record arguments")
    125125                        return False
    126126               
     
    134134                srcfqname = os.path.join(base, srcfname)
    135135                if (not os.path.isfile(srcfqname)):
    136                         print "Source %s not found" % srcfqname
     136                        print("Source %s not found" % srcfqname)
    137137                        return False
    138138               
     
    153153               
    154154                # Run Vcc
    155                 print " -- %s --" % srcfname           
     155                print(" -- %s --" % srcfname)
    156156                retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait()
    157157               
     
    182182       
    183183        if (not os.path.isfile(vcc_path)):
    184                 print "%s is not a binary." % vcc_path
    185                 print "Please supply the full Cygwin path to Vcc as the second argument."
     184                print("%s is not a binary." % vcc_path)
     185                print("Please supply the full Cygwin path to Vcc as the second argument.")
    186186                return
    187187       
     
    189189       
    190190        if (not os.path.isfile(config)):
    191                 print "%s not found." % config
    192                 print "Please specify the path to HelenOS build tree root as the first argument."
     191                print("%s not found." % config)
     192                print("Please specify the path to HelenOS build tree root as the first argument.")
    193193                return
    194194       
    195195        specpath = os.path.join(rootdir, "tools/checkers/vcc.h")
    196196        if (not os.path.isfile(specpath)):
    197                 print "%s not found." % config
     197                print("%s not found." % config)
    198198                return
    199199       
     
    205205                if (not vcc(vcc_path, rootdir, job)):
    206206                        print
    207                         print "Failed job: %s" % job
     207                        print("Failed job: %s" % job)
    208208                        return
    209209       
    210210        print
    211         print "All jobs passed"
     211        print("All jobs passed")
    212212
    213213if __name__ == '__main__':
  • tools/config.py

    r458619f7 r28f4adb  
    4848        "Read saved values from last configuration run"
    4949       
    50         inf = file(fname, 'r')
     50        inf = open(fname, 'r')
    5151       
    5252        for line in inf:
     
    103103                condval = res.group(3)
    104104               
    105                 if (not defaults.has_key(condname)):
     105                if (not condname in defaults):
    106106                        varval = ''
    107107                else:
     
    131131        "Parse configuration file"
    132132       
    133         inf = file(fname, 'r')
     133        inf = open(fname, 'r')
    134134       
    135135        name = ''
     
    219219                        continue
    220220               
    221                 if (not defaults.has_key(varname)):
     221                if (not varname in defaults):
    222222                        return False
    223223       
     
    232232       
    233233        try:
    234                 version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].split(':')
     234                version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].decode().split(':')
    235235                sys.stderr.write("ok\n")
    236236        except:
     
    246246                revision = None
    247247       
    248         outmk = file(mkname, 'w')
    249         outmc = file(mcname, 'w')
     248        outmk = open(mkname, 'w')
     249        outmc = open(mcname, 'w')
    250250       
    251251        outmk.write('#########################################\n')
     
    263263                        continue
    264264               
    265                 if (not defaults.has_key(varname)):
     265                if (not varname in defaults):
    266266                        default = ''
    267267                else:
     
    368368                        # Cancel out all defaults which have to be deduced
    369369                        for varname, vartype, name, choices, cond in ask_names:
    370                                 if ((vartype == 'y') and (defaults.has_key(varname)) and (defaults[varname] == '*')):
     370                                if ((vartype == 'y') and (varname in defaults) and (defaults[varname] == '*')):
    371371                                        defaults[varname] = None
    372372                       
     
    385385                                        position = cnt
    386386                               
    387                                 if (not defaults.has_key(varname)):
     387                                if (not varname in defaults):
    388388                                        default = None
    389389                                else:
     
    428428                                cnt += 1
    429429                       
    430                         if (position >= options):
     430                        if (position != None) and (position >= len(options)):
    431431                                position = None
    432432                       
     
    449449                       
    450450                        position = None
    451                         if (not opt2row.has_key(value)):
     451                        if (not value in opt2row):
    452452                                raise RuntimeError("Error selecting value: %s" % value)
    453453                       
    454454                        (selname, seltype, name, choices) = opt2row[value]
    455455                       
    456                         if (not defaults.has_key(selname)):
     456                        if (not selname in defaults):
    457457                                        default = None
    458458                        else:
  • tools/jobfile.py

    r458619f7 r28f4adb  
    3838def usage(prname):
    3939        "Print usage syntax"
    40         print prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]"
     40        print(prname + " <JOBFILE> <SOURCE> <TARGET> <TOOL> <CATEGORY> [OPTIONS ...]")
    4141
    4242def main():
     
    5353        options = " ".join(sys.argv[6:])
    5454       
    55         jobfile = file(jobfname, "a")
     55        jobfile = open(jobfname, "a")
    5656        fcntl.lockf(jobfile, fcntl.LOCK_EX)
    5757        jobfile.write("{%s},{%s},{%s},{%s},{%s},{%s}\n" % (srcfname, tgtfname, toolname, category, cwd, options))
  • tools/mkfat.py

    r458619f7 r28f4adb  
    4646                return size
    4747       
    48         return (((size / alignment) + 1) * alignment)
     48        return ((size // alignment) + 1) * alignment
    4949
    5050def subtree_size(root, cluster_size, dirent_size):
     
    7979        first = 0
    8080       
    81         inf = file(path, "r")
     81        inf = open(path, "rb")
    8282        rd = 0;
    8383        while (rd < size):
     
    9292                prev = empty_cluster
    9393               
    94                 data = inf.read(cluster_size);
     94                data = bytes(inf.read(cluster_size));
    9595                outf.seek(data_start + (empty_cluster - reserved_clusters) * cluster_size)
    9696                outf.write(data)
     
    120120                prev = empty_cluster
    121121               
    122                 data = ''
     122                data = bytes()
    123123                data_len = 0
    124124                while ((i < length) and (data_len < cluster_size)):
     
    343343def usage(prname):
    344344        "Print usage syntax"
    345         print prname + " <EXTRA_BYTES> <PATH> <IMAGE>"
     345        print(prname + " <EXTRA_BYTES> <PATH> <IMAGE>")
    346346
    347347def main():
     
    351351       
    352352        if (not sys.argv[1].isdigit()):
    353                 print "<EXTRA_BYTES> must be a number"
     353                print("<EXTRA_BYTES> must be a number")
    354354                return
    355355       
     
    358358        path = os.path.abspath(sys.argv[2])
    359359        if (not os.path.isdir(path)):
    360                 print "<PATH> must be a directory"
     360                print("<PATH> must be a directory")
    361361                return
    362362       
     
    372372        # Make sure the filesystem is large enought for FAT16
    373373        size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes
    374         while (size / cluster_size < fat16_clusters):
     374        while (size // cluster_size < fat16_clusters):
    375375                if (cluster_size > sector_size):
    376                         cluster_size /= 2
     376                        cluster_size = cluster_size // 2
    377377                        size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size + extra_bytes
    378378                else:
     
    381381        root_size = align_up(root_entries(path) * dirent_size, cluster_size)
    382382       
    383         fat_size = align_up(align_up(size, cluster_size) / cluster_size * fatent_size, sector_size)
    384        
    385         sectors = (cluster_size + fat_count * fat_size + root_size + size) / sector_size
     383        fat_size = align_up(align_up(size, cluster_size) // cluster_size * fatent_size, sector_size)
     384       
     385        sectors = (cluster_size + fat_count * fat_size + root_size + size) // sector_size
    386386        root_start = cluster_size + fat_count * fat_size
    387387        data_start = root_start + root_size
    388388       
    389         outf = file(sys.argv[3], "w")
     389        outf = open(sys.argv[3], "wb")
    390390       
    391391        boot_sector = xstruct.create(BOOT_SECTOR)
    392392        boot_sector.jmp = [0xEB, 0x3C, 0x90]
    393         boot_sector.oem = "MSDOS5.0"
     393        boot_sector.oem = b'MSDOS5.0'
    394394        boot_sector.sector = sector_size
    395         boot_sector.cluster = cluster_size / sector_size
    396         boot_sector.reserved = cluster_size / sector_size
     395        boot_sector.cluster = cluster_size // sector_size
     396        boot_sector.reserved = cluster_size // sector_size
    397397        boot_sector.fats = fat_count
    398         boot_sector.rootdir = root_size / dirent_size
     398        boot_sector.rootdir = root_size // dirent_size
    399399        if (sectors <= 65535):
    400400                boot_sector.sectors = sectors
     
    402402                boot_sector.sectors = 0
    403403        boot_sector.descriptor = 0xF8
    404         boot_sector.fat_sectors = fat_size / sector_size
     404        boot_sector.fat_sectors = fat_size // sector_size
    405405        boot_sector.track_sectors = 63
    406406        boot_sector.heads = 6
     
    414414        boot_sector.extboot_signature = 0x29
    415415        boot_sector.serial = random.randint(0, 0x7fffffff)
    416         boot_sector.label = "HELENOS"
    417         boot_sector.fstype = "FAT16   "
     416        boot_sector.label = b'HELENOS'
     417        boot_sector.fstype = b'FAT16   '
    418418        boot_sector.boot_signature = [0x55, 0xAA]
    419419       
     
    423423       
    424424        # Reserved sectors
    425         for i in range(1, cluster_size / sector_size):
     425        for i in range(1, cluster_size // sector_size):
    426426                outf.write(empty_sector.pack())
    427427       
    428428        # FAT tables
    429429        for i in range(0, fat_count):
    430                 for j in range(0, fat_size / sector_size):
     430                for j in range(0, fat_size // sector_size):
    431431                        outf.write(empty_sector.pack())
    432432       
    433433        # Root directory
    434         for i in range(0, root_size / sector_size):
     434        for i in range(0, root_size // sector_size):
    435435                outf.write(empty_sector.pack())
    436436       
    437437        # Data
    438         for i in range(0, size / sector_size):
     438        for i in range(0, size // sector_size):
    439439                outf.write(empty_sector.pack())
    440440       
    441         fat = array.array('L', [0] * (fat_size / fatent_size))
     441        fat = array.array('L', [0] * (fat_size // fatent_size))
    442442        fat[0] = 0xfff8
    443443        fat[1] = 0xffff
     
    449449        for i in range(0, fat_count):
    450450                outf.seek(cluster_size + i * fat_size)
    451                 for j in range(0, fat_size / fatent_size):
     451                for j in range(0, fat_size // fatent_size):
    452452                        fat_entry.next = fat[j]
    453453                        outf.write(fat_entry.pack())
  • tools/mkhord.py

    r458619f7 r28f4adb  
    5252def usage(prname):
    5353        "Print usage syntax"
    54         print prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>"
     54        print(prname + " <ALIGNMENT> <FS_IMAGE> <HORD_IMAGE>")
    5555
    5656def main():
     
    6060       
    6161        if (not sys.argv[1].isdigit()):
    62                 print "<ALIGNMENT> must be a number"
     62                print("<ALIGNMENT> must be a number")
    6363                return
    6464       
    6565        align = int(sys.argv[1], 0)
    6666        if (align <= 0):
    67                 print "<ALIGNMENT> must be positive"
     67                print("<ALIGNMENT> must be positive")
    6868                return
    6969       
    7070        fs_image = os.path.abspath(sys.argv[2])
    7171        if (not os.path.isfile(fs_image)):
    72                 print "<FS_IMAGE> must be a file"
     72                print("<FS_IMAGE> must be a file")
    7373                return
    7474       
    75         inf = file(fs_image, "rb")
    76         outf = file(sys.argv[3], "wb")
     75        inf = open(fs_image, "rb")
     76        outf = open(sys.argv[3], "wb")
    7777       
    7878        header = xstruct.create(HEADER)
  • tools/mktmpfs.py

    r458619f7 r28f4adb  
    6666def usage(prname):
    6767        "Print usage syntax"
    68         print prname + " <PATH> <IMAGE>"
     68        print(prname + " <PATH> <IMAGE>")
    6969
    7070def recursion(root, outf):
     
    8585                        outf.write(dentry.pack())
    8686                       
    87                         inf = file(canon, "r")
     87                        inf = open(canon, "rb")
    8888                        rd = 0;
    8989                        while (rd < size):
     
    116116        path = os.path.abspath(sys.argv[1])
    117117        if (not os.path.isdir(path)):
    118                 print "<PATH> must be a directory"
     118                print("<PATH> must be a directory")
    119119                return
    120120       
    121         outf = file(sys.argv[2], "w")
     121        outf = open(sys.argv[2], "wb")
    122122       
    123123        header = xstruct.create(HEADER)
  • tools/mkuimage.py

    r458619f7 r28f4adb  
    7272                        start_addr = (int)(optarg, 0)
    7373                else:
    74                         print base_name + ": Unrecognized option."
     74                        print(base_name + ": Unrecognized option.")
    7575                        print_syntax(cmd_name)
    7676                        return
    7777
    7878        if len(args) < 2:
    79                 print base_name + ": Argument missing."
     79                print(base_name + ": Argument missing.")
    8080                print_syntax(cmd_name)
    8181                return
     
    9191
    9292def mkuimage(inf_name, outf_name, image_name, load_addr, start_addr):
    93         inf = file(inf_name, 'rb')
    94         outf = file(outf_name, 'wb')
     93        inf = open(inf_name, 'rb')
     94        outf = open(outf_name, 'wb')
    9595
    9696        header = xstruct.create(UIMAGE_HEADER)
     
    140140        signed_crc = zlib.crc32(byteseq, 0)
    141141        if signed_crc < 0:
    142                 return (long(signed_crc) + 4294967296L) # 2^32L
     142                return (long(signed_crc) + (long(2) ** long(32))) # 2^32L
    143143        else:
    144144                return signed_crc
     
    147147#
    148148def print_syntax(cmd):
    149         print "syntax: " + cmd + " [<options>] <raw_image> <uImage>"
     149        print("syntax: " + cmd + " [<options>] <raw_image> <uImage>")
    150150        print
    151         print "\traw_image\tInput image name (raw binary data)"
    152         print "\tuImage\t\tOutput uImage name (U-Boot image)"
     151        print("\traw_image\tInput image name (raw binary data)")
     152        print("\tuImage\t\tOutput uImage name (U-Boot image)")
    153153        print
    154         print "options:"
    155         print "\t-name <name>\tImage name (default: 'Noname')"
    156         print "\t-laddr <name>\tLoad address (default: 0x00000000)"
    157         print "\t-saddr <name>\tStart address (default: 0x00000000)"
     154        print("options:")
     155        print("\t-name <name>\tImage name (default: 'Noname')")
     156        print("\t-laddr <name>\tLoad address (default: 0x00000000)")
     157        print("\t-saddr <name>\tStart address (default: 0x00000000)")
    158158
    159159if __name__ == '__main__':
  • tools/pack.py

    r458619f7 r28f4adb  
    4343def usage(prname):
    4444        "Print usage syntax"
    45         print "%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname
     45        print("%s <OBJCOPY> <FORMAT> <ARCH> <ARCH_PATH> [COMPONENTS ...]" % prname)
    4646
    4747def deflate(data):
     
    110110                symbol = "_binary_%s" % basename.replace(".", "_")
    111111               
    112                 print "%s -> %s" % (component, obj)
     112                print("%s -> %s" % (component, obj))
    113113               
    114                 comp_in = file(component, "rb")
     114                comp_in = open(component, "rb")
    115115                comp_data = comp_in.read()
    116116                comp_in.close()
     
    121121               
    122122                try:
    123                         comp_out = file(basename, "wb")
     123                        comp_out = open(basename, "wb")
    124124                        comp_out.write(comp_deflate)
    125125                        comp_out.close()
     
    151151                cnt += 1
    152152       
    153         header = file(os.path.join(arch_path, "include", "%s.h" % COMPONENTS), "w")
     153        header = open(os.path.join(arch_path, "include", "%s.h" % COMPONENTS), "w")
    154154       
    155155        header.write('/***************************************\n')
     
    173173        header.close()
    174174       
    175         data = file(os.path.join(arch_path, "src", "%s.c" % COMPONENTS), "w")
     175        data = open(os.path.join(arch_path, "src", "%s.c" % COMPONENTS), "w")
    176176       
    177177        data.write('/***************************************\n')
     
    187187        data.close()
    188188       
    189         link_in = file(os.path.join(arch_path, "%s.in" % LINK), "r")
     189        link_in = open(os.path.join(arch_path, "%s.in" % LINK), "r")
    190190        template = link_in.read()
    191191        link_in.close()
    192192       
    193         link_out = file(os.path.join(arch_path, "%s.comp" % LINK), "w")
     193        link_out = open(os.path.join(arch_path, "%s.comp" % LINK), "w")
    194194        link_out.write(template.replace("[[COMPONENTS]]", "\n".join(link_ctx)))
    195195        link_out.close()
Note: See TracChangeset for help on using the changeset viewer.