elec2geo.py
Go to the documentation of this file.
1 import psycopg2
2 import csv
3 import sys
4 
5 try:
6  conn = psycopg2.connect("dbname=nova_hardware host=ifdbprod.fnal.gov user=nova_reader port=5432")
7 except:
8  print "I am unable to connect to the database"
9  exit(0)
10 
11 cur = conn.cursor()
12 
13 #SQL = "set search_path to ashriverprod_factory;"
14 #cur.execute(SQL)
15 
16 #print "__________________________________"
17 #print "looking for diblock {} dcm {} port {}".format(sys.argv[1],sys.argv[2],sys.argv[3])
18 
19 
20 SQL = "select CAST(btrim(location2, 'BLK:') AS INT), CAST(btrim(position2, 'PLN:') AS INT), CAST(btrim(port2,'POS:') AS INT) from public.feb_comm_cables where location1='DIBLK:{}' and position1='DCM:{}' and port1='PRT:{}';".format(sys.argv[1],sys.argv[2],sys.argv[3])
21 
22 #print SQL
23 
24 cur.execute(SQL)
25 
26 rows = cur.fetchall()
27 #print "I found {} rows".format(cur.rowcount)
28 for row in rows:
29 ### print "ROW IS "
30 # print row
31  block = row[0]
32  layer = row[1]
33  pos = row[2]
34  print "DCM-2-{}-{} FEB {} corresponds to block: {} layer: {} Pos: {} ".format(sys.argv[1],sys.argv[2],sys.argv[3],block,layer,pos)
35 
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
exit(0)