#!/usr/bin/python # # # 02/06/2016 Paul Mattione # # # This script moves the TAC adc counter. # import sqlite3 as lite import sys import os import re import datetime if len(sys.argv) != 2: print "You must supply a SQLite DB file to modify!" sys.exit(0); # Connect to SQLite DB file db_filename = sys.argv[1] print "" print "opening SQLite DB file: %s" % db_filename print "---------------------------------------------" con = lite.connect(db_filename) with con: # Specify that next cursor should be "dictionary" # (i.e. python's hash map) so columns can be indexed # by name con.row_factory = lite.Row # Create Cursor cur = con.cursor() # Check that this TT file has not already been updated cur.execute("SELECT * FROM TAC WHERE adc_chanid=27172") rf_rows = cur.fetchall() if len(rf_rows) != 0: print 'TAC adc channel already moved!' sys.exit(-1) #update TAC table cur.execute("UPDATE TAC SET adc_chanid=27172 WHERE adc_chanid=24342") # Add module for TAC (moduleid|crateid|slot|type|SN) cur.execute("INSERT INTO Module Values (1029, 67, 20, 'fADC250', '')") # Add channels for TAC (chanid|moduleid|name|channel|system|col_name|enable) cur.execute("INSERT INTO Channel Values (27172, 1029, 'TAC-A', 0, 'TAC', 'adc_chanid', 1)") # Revert old TAC channel back to FCAL-unused cur.execute("UPDATE Channel SET name='FCAL-unused', system='', col_name='' WHERE chanid='24342'") print 'Done'