Skip to content

Commit 057e810

Browse files
authored
Merge pull request #695 from OSU-CMS/useRhApiClass
Use RhApi class instead of using subprocesses
2 parents a0eec95 + a97a411 commit 057e810

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Gui/python/CentralDBInterface.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import os
2+
from Gui.python.rhapi import RhApi
23

4+
5+
#FIXME: Add the login part of the api.
36
def DCA_login():
47
DB_login_command = f'python python/rhapi.py --login --no-save-password --clean -u https://cmsdca.cern.ch/trk_rhapi1'
58
DB_login_output = os.popen(DB_login_command).read()
69
return DB_login_output.strip("\n")
710
def ExtractChipData(chipserial):
8-
DB_interface_step1 = f'''python python/rhapi.py --login --no-save-password --clean -u https://cmsdca.cern.ch/trk_rhapi1 "select c.* from trker_cmsr.c18220 c where c.PART_NAME_LABEL = '{chipserial}'"'''
9-
DB_interface_step2 = f'''python python/rhapi.py --login --no-save-password --clean -u https://cmsdca.cern.ch/trk_rhapi1 "select c.CROC_DATA_ID, c.Y from trker_cmsr.c18240 c where c.PART_NAME_LABEL = '{chipserial}' and c.CROC_DATA_ID like 'DAC_%_LIN' and c.X = 0"'''
10-
chipdataoutput_step1 = os.popen(DB_interface_step1).read()
11+
api = RhApi(url="https://cmsdca.cern.ch/trk_rhapi1", sso="login", save_password=False)
12+
chipdataoutput_step1 = api.data(api.qid("select c.* from trker_cmsr.c18220 c where c.PART_NAME_LABEL = '{}'".format(chipserial)))
13+
14+
#DB_interface_step1 = f'''python python/rhapi.py --login --no-save-password --clean -u https://cmsdca.cern.ch/trk_rhapi1 "select c.* from trker_cmsr.c18220 c where c.PART_NAME_LABEL = '{chipserial}'"'''
15+
#DB_interface_step2 = f'''python python/rhapi.py --login --no-save-password --clean -u https://cmsdca.cern.ch/trk_rhapi1 "select c.CROC_DATA_ID, c.Y from trker_cmsr.c18240 c where c.PART_NAME_LABEL = '{chipserial}' and c.CROC_DATA_ID like 'DAC_%_LIN' and c.X = 0"'''
16+
#chipdataoutput_step1 = os.popen(DB_interface_step1).read()
1117
chipdataoutput_step1 = chipdataoutput_step1.split("\n")
1218
datelabel_step1 = chipdataoutput_step1[0].split(",")
1319
datavalue_step1 = chipdataoutput_step1[1].split(",")
1420
chipdata_step1 = dict(zip(datelabel_step1, datavalue_step1))
15-
chipdataoutput = os.popen(DB_interface_step2).read()
21+
chipdataoutput = api.data(api.qid("select c.CROC_DATA_ID, c.Y from trker_cmsr.c18240 c where c.PART_NAME_LABEL = '{}' and c.CROC_DATA_ID like 'DAC_%_LIN' and c.X = 0".format(chipserial)))
22+
#chipdataoutput = os.popen(DB_interface_step2).read()
1623
chipdataoutput = chipdataoutput.split("\n")
1724
chipdata = {}
1825
for entry in chipdataoutput:

0 commit comments

Comments
 (0)