Exemplo n.º 1
0
        if len(args) > 2:
            raise getopt.GetoptError('Too many arguments')

    except getopt.GetoptError:
        msg = sys.exc_info()[1]     # current exception
        txt = 'ERROR: '+str(msg)    # that's required to get not-so-dumb result from 2to3 tool
        print(txt)
        print(usage)
        sys.exit(2)

    from intelhex import compat

    fin = args[0]
    if fin == '-':
        # read from stdin
        fin = compat.get_binary_stdin()
    elif not os.path.isfile(fin):
        txt = "ERROR: File not found: %s" % fin   # that's required to get not-so-dumb result from 2to3 tool
        print(txt)
        sys.exit(1)

    if len(args) == 2:
        fout = args[1]
    else:
        # write to stdout
        fout = sys.stdout   # compat.get_binary_stdout()

    from intelhex import bin2hex
    sys.exit(bin2hex(fin, fout, offset))
Exemplo n.º 2
0
        if len(args) > 2:
            raise getopt.GetoptError('Too many arguments')

    except getopt.GetoptError:
        msg = sys.exc_info()[1]  # current exception
        txt = 'ERROR: ' + str(
            msg)  # that's required to get not-so-dumb result from 2to3 tool
        print(txt)
        print(usage)
        sys.exit(2)

    from intelhex import compat

    fin = args[0]
    if fin == '-':
        # read from stdin
        fin = compat.get_binary_stdin()
    elif not os.path.isfile(fin):
        txt = "ERROR: File not found: %s" % fin  # that's required to get not-so-dumb result from 2to3 tool
        print(txt)
        sys.exit(1)

    if len(args) == 2:
        fout = args[1]
    else:
        # write to stdout
        fout = sys.stdout  # compat.get_binary_stdout()

    from intelhex import bin2hex
    sys.exit(bin2hex(fin, fout, offset))