#!	/usr/bin/env python

import sys
import cx_Oracle

query = '''
select cratelabel, bus_loop, module_crate, function 
from crates_v
where compname = :fecname
order by bus_loop, module_crate
'''

try:
    fecname = sys.argv[1]
except:
    print "usage: %s hostname" % sys.argv[0]
    sys.exit(1)

con = cx_Oracle.connect('copub/p3b_c0nfig')
cur = con.cursor()

cur.execute(query, fecname = fecname)
for label, loop, rti, desc in cur.fetchall():
	if loop is None:
		continue
	print '%-16s\t%1d\t%02d' % (label, loop, rti)

