if not args: raise getopt.GetoptError('Hex file is not specified') 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) fin = args[0] if 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 from intelhex import compat fout = compat.get_binary_stdout() from intelhex import hex2bin sys.exit(hex2bin(fin, fout, start, end, size, pad))
raise getopt.GetoptError('Cannot specify START:END and SIZE simultaneously') if not args: raise getopt.GetoptError('Hex file is not specified') 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) fin = args[0] if 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 from intelhex import compat fout = compat.get_binary_stdout() from intelhex import hex2bin sys.exit(hex2bin(fin, fout, start, end, size, pad))