Skip to content

Commit

Permalink
uHAL : Update tools to support Python 3; refs #127
Browse files Browse the repository at this point in the history
  • Loading branch information
tswilliams committed Jan 4, 2019
1 parent 156f4aa commit 29665dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 10 additions & 3 deletions uhal/tools/scripts/gen_ipbus_addr_decode
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ options:
(default
/opt/cactus/etc/uhal/tools/ipbus_addr_decode.vhd)
"""

from __future__ import print_function

import getopt
import sys
import os.path
Expand All @@ -27,6 +30,10 @@ import math
import uhal

#===========================================================================================
# In Python 3 "xrange" doesn't exist, since Python 3's "range" is just as efficient as Python 2's "xrange"
if (sys.version_info[0] > 2):
xrange = range


class BitArray:

Expand Down Expand Up @@ -189,7 +196,7 @@ def main():
template_fn = "/opt/cactus/etc/uhal/tools/ipbus_addr_decode.vhd"
try:
opts, args = getopt.getopt(sys.argv[1:], "vdnht:", ["verbose","debug","dry-run","help","template="])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
log.critical(__doc__)
sys.exit(EXIT_CODE_ARG_PARSING_ERROR)
for o, a in opts:
Expand All @@ -200,7 +207,7 @@ def main():
log.setLevel(logging.DEBUG)
uhal.setLogLevelTo(uhal.LogLevel.DEBUG)
elif o in ("-h", "--help"):
print __doc__
print(__doc__)
sys.exit(0)
elif o in ("-t", "--template"):
template_fn = a
Expand Down Expand Up @@ -300,7 +307,7 @@ def main():
.replace("INSERT_SEL_WIDTH_HERE","%s"%ipbus_sel_width)\
.replace("PACKAGENAME",moduleName))
vhdlfile.close()
print "VHDL decode file saved: ", vhdlfilename
print("VHDL decode file saved: ", vhdlfilename)

if __name__ == '__main__':
main()
Expand Down
6 changes: 4 additions & 2 deletions uhal/tools/scripts/uhal_inspect_registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
This script prints the values in a remote device, of registers below a specified uHAL node.
"""

from __future__ import print_function

import argparse
import uhal

Expand Down Expand Up @@ -43,8 +45,8 @@ def snapshot(node, regex):
cm = uhal.ConnectionManager(args.conn_file)
device = cm.getDevice(args.device_id)

print 'Values of registers below node "'+args.reg_name+'" in device "'+args.device_id+'"'
print('Values of registers below node "'+args.reg_name+'" in device "'+args.device_id+'"')

for name, value in snapshot(device.getNode(args.reg_name), args.regex):
print " +", name, ":", hex(value)
print(" +", name, ":", hex(value))

0 comments on commit 29665dc

Please sign in to comment.