Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Configuration/XMLUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import logging

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
from Gui.python.logging_config import get_logger
logger = get_logger(__name__)

PH2ACF_VERSION = os.environ.get("PH2ACF_VERSION")

Expand All @@ -36,20 +36,20 @@ def LoadXML(filename="CMSIT.xml"):

def ShowXMLTree(XMLroot, depth=0):
depth += 1
print("--"*(depth-1), "|", XMLroot.tag, XMLroot.attrib, XMLroot.text)
logger.info("--"*(depth-1), "|", XMLroot.tag, XMLroot.attrib, XMLroot.text)
for child in XMLroot:
ShowXMLTree(child,depth)

def ModifyBeboard(XMLroot, BeboardModule):
def __init__(self):
print("Nothing Done")
logger.info("Nothing Done")

class HWDescription():
def __init__(self):
self.BeBoardList = []
self.Settings = {}
self.MonitoringList = []
print("Setting HWDescription")
logger.info("Setting HWDescription")

def AddBeBoard(self, BeBoardModule):
self.BeBoardList.append(BeBoardModule)
Expand Down Expand Up @@ -278,7 +278,7 @@ def GenerateHWDescriptionXML(HWDescription,outputFile = "CMSIT_gen.xml", boardty
#Node_connection.Set('id',BeBoard.id)
#Node_connection.Set('uri',BeBoard.uri)
#Node_connection.Set('address_table',BeBoard.address_table)
print('beboard ip is {0}'.format(BeBoard.uri))
logger.info('beboard ip is {0}'.format(BeBoard.uri))
Node_connection = SetNodeAttribute(Node_connection,{'id':BeBoard.id,'uri':BeBoard.uri,'address_table':BeBoard.address_table})
OpticalGroupList = BeBoard.OpticalGroupList

Expand Down Expand Up @@ -306,14 +306,14 @@ def GenerateHWDescriptionXML(HWDescription,outputFile = "CMSIT_gen.xml", boardty
##FIXME Add in logic to change depending on version of Ph2_ACF -> Done!

HyBridModule.SetHyBridType('RD53') #This part should stay as just RD53 (no A or B)
print("This is the Hybrid Type: ", HyBridModule.HyBridType)
logger.info("This is the Hybrid Type: ", HyBridModule.HyBridType)
Node_FEPath = ET.SubElement(Node_HyBrid, HyBridModule.HyBridType+'_Files')
Node_FEPath = SetNodeAttribute(Node_FEPath,{'file':HyBridModule.File_Path})
FEList = HyBridModule.FEList
### This is where the RD53 block is being made ###
for FE in FEList:
BeBoard.boardType = boardtype
print("This is the board type: ", BeBoard.boardType)
logger.info("This is the board type: ", BeBoard.boardType)
Node_FE = ET.SubElement(Node_HyBrid, BeBoard.boardType)
if 'v1' in boardtype:
Node_FE = SetNodeAttribute(Node_FE,{'Id':FE.Id, 'enable':FE.Enabled,'Lane':FE.Lane, 'eFuseCode':FE.EfuseID,'IrefCode':'-1','configFile':FE.configfile,'RxGroups':FE.RxGroups,'RxPolarity':FE.RxPolarities,'TxGroup':FE.TxGroups,'TxChannel':FE.TxChannels,'TxPolarity':FE.TxPolarities,'Comment':boardtype})
Expand Down
20 changes: 12 additions & 8 deletions Configuration/dataExtraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@




from Gui.python.logging_config import get_logger
logger = get_logger(__name__)

def GetTrims(password,serialNumber,debug = False):
connection = mysql.connector.connect(
host="cmsfpixdb.physics.purdue.edu",
Expand All @@ -25,21 +29,21 @@ def GetTrims(password,serialNumber,debug = False):
cursor.execute(f"select component.id from component where component.serial_number='{serialNumber}';")
results = cursor.fetchall()
if debug == True:
print("raw ID:"+str(result))# it should look like [(778,)]
logger.debug("raw ID:"+str(result))# it should look like [(778,)]
parenetNum = results[0][0]

cursor.execute(f"select component.description from component where component.serial_number='{serialNumber}';")
results = cursor.fetchall() #[('TFPX CROC 1x2 HPK sensor module',)]
if debug == True:
print("raw description"+str(results))
logger.debug("raw description"+str(results))

if "sensor" in str(results[0][0]):
cursor.execute(f"select component.id from component where component.parent='{parenetNum}';")
chipSensorResult=cursor.fetchall()
secondParent=chipSensorResult[0][0]
if debug == True:
print("it is sensor module")
print("secondParent" + str(secondParent))
logger.debug("it is sensor module")
logger.debug("secondParent" + str(secondParent))
parenetNum = secondParent


Expand All @@ -53,7 +57,7 @@ def GetTrims(password,serialNumber,debug = False):
VDDAList.append([siteNum,VDDA])
sorted_VDDAlist = sorted(VDDAList, key=lambda x: x[0])
if debug == True:
print("sorted_VDDAlist:"+str(sorted_VDDAlist))
logger.debug("sorted_VDDAlist:"+str(sorted_VDDAlist))



Expand All @@ -67,7 +71,7 @@ def GetTrims(password,serialNumber,debug = False):

sorted_VDDDlist = sorted(VDDDList, key=lambda x: x[0]) #make sure the we can get VDDD value base on the order of rising chip no
if debug == True:
print("sorted_VDDDlist:" + str(sorted_VDDDlist))
logger.debug("sorted_VDDDlist:" + str(sorted_VDDDlist))
connection.close()
return sorted_VDDAlist,sorted_VDDDlist

Expand All @@ -76,7 +80,7 @@ def GetTrims(password,serialNumber,debug = False):
password = getpass.getpass("Enter your password:")
serialNumber = "RH0001"
sorted_VDDAlist,sorted_VDDDlist=GetTrims(password,serialNumber)
print("sorted_VDDAlist(in order site,trim value):" + str(sorted_VDDAlist))
print("VDDD:" + str(sorted_VDDDlist))
logger.info("sorted_VDDAlist(in order site,trim value):" + str(sorted_VDDAlist))
logger.info("VDDD:" + str(sorted_VDDDlist))


7 changes: 5 additions & 2 deletions F4T_Monitoring/F4TMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import matplotlib, threading, time, csv, yagmail, os
from datetime import datetime

from Gui.python.logging_config import get_logger
logger = get_logger(__name__)

class F4TMonitor():
def __init__(self):
self.alertRecipients=[] #emails
Expand Down Expand Up @@ -90,7 +93,7 @@ def updateData(self):
try:
data, _ = self.sock.recvfrom(2048)
data = data.decode('utf-8')
print(data)
logger.info(data)

if data[0]=="!":
self.logFile="dht_logs_"+datetime.now().strftime("%Y-%m-%d %H:%M:%S")+".csv"
Expand Down Expand Up @@ -122,7 +125,7 @@ def updateData(self):
string = "Arduino connection timed out."
else:
string = str(e)
print(e)
logger.error(e)
self.tailData.insert(0,string)
if len(self.tailData)>6: self.tailData.pop()

Expand Down
56 changes: 29 additions & 27 deletions Gui/GUIutils/DBConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import traceback

from PyQt5.QtWidgets import QMessageBox
from Gui.python.logging_config import get_logger
logger = get_logger(__name__)

# from Gui.GUIutils.settings import *
from Gui.GUIutils.guiUtils import (
isActive,
formatter,
)

Check failure on line 24 in Gui/GUIutils/DBConnection.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

Gui/GUIutils/DBConnection.py:21:1: E402 Module level import not at top of file

Check failure on line 24 in Gui/GUIutils/DBConnection.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

Gui/GUIutils/DBConnection.py:21:1: E402 Module level import not at top of file
from InnerTrackerTests.TestSequences import Test_to_Ph2ACF_Map

Check failure on line 25 in Gui/GUIutils/DBConnection.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

Gui/GUIutils/DBConnection.py:25:1: E402 Module level import not at top of file

Check failure on line 25 in Gui/GUIutils/DBConnection.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

Gui/GUIutils/DBConnection.py:25:1: E402 Module level import not at top of file

DB_TestResult_Schema = [
"Module_ID, Account, CalibrationName, ExecutionTime, Grading, DQMFile"
Expand Down Expand Up @@ -50,8 +52,8 @@
connection_timeout=5000,
)
except (ValueError, RuntimeError, TypeError, NameError, mysql.connector.Error) as err:
print("Error establishing connection:", err)
print(traceback.format_exc())
logger.error("Error establishing connection:", err)
logger.error(traceback.format_exc())
msg = QMessageBox()
msg.information(
None,
Expand Down Expand Up @@ -178,12 +180,12 @@
test = formatter(dirName, columns, part_id=str(module_id))
localTests.append(test)
except Exception as err:
print(
logger.error(
"Error detected while formatting the directory name, {}".format(
repr(err)
)
)
print(traceback.format_exc())
logger.error(traceback.format_exc())
else:
for dirName in dirList:
# getFiles = subprocess.run('find {0} -mindepth 1 -maxdepth 1 -type f -name "*.root" '.format(dirName), shell=True, stdout=subprocess.PIPE)
Expand All @@ -201,12 +203,12 @@
)
localTests.append(test)
except Exception as err:
print(
logger.error(
"Error detected while formatting the directory name, {}".format(
repr(err)
)
)
print(traceback.format_exc())
logger.error(traceback.format_exc())
return localTests


Expand Down Expand Up @@ -310,8 +312,8 @@
header = list(map(lambda x: alltuple[x][0], range(0, len(alltuple))))
return list(compress(header, auto_incre_filter))
except mysql.connector.Error as error:
print("Failed describing MySQL table:", error)
print(traceback.format_exc())
logger.error("Failed describing MySQL table:", error)
logger.error(traceback.format_exc())
return []


Expand Down Expand Up @@ -345,8 +347,8 @@
allList = [list(i) for i in alltuple]
return allList
except mysql.connector.Error as error:
print("Failed retrieving MySQL table:", error)
print(traceback.format_exc())
logger.error("Failed retrieving MySQL table:", error)
logger.error(traceback.format_exc())
return []


Expand Down Expand Up @@ -374,8 +376,8 @@
allList = [list(i) for i in alltuple]
return allList
except mysql.connector.Error as error:
print("Failed retrieving MySQL table:{}".format(error))
print(traceback.format_exc())
logger.error("Failed retrieving MySQL table:{}".format(error))
logger.error(traceback.format_exc())
return []


Expand All @@ -400,8 +402,8 @@
allList = [list(i) for i in alltuple]
return allList
except Exception as error:
print("Failed retrieving MySQL table:{}".format(error))
print(traceback.format_exc())
logger.error("Failed retrieving MySQL table:{}".format(error))
logger.error(traceback.format_exc())
return []


Expand All @@ -425,8 +427,8 @@
dbconnection.commit()
return True
except Exception as error:
print("Failed inserting MySQL table {}: {}".format(table, error))
print(traceback.format_exc())
logger.error("Failed inserting MySQL table {}: {}".format(table, error))
logger.error(traceback.format_exc())
return False


Expand All @@ -446,8 +448,8 @@
dbconnection.commit()
return True
except Exception as err:
print("Failed to create new user:", err)
print(traceback.format_exc())
logger.error("Failed to create new user:", err)
logger.error(traceback.format_exc())
return False


Expand Down Expand Up @@ -492,8 +494,8 @@
dbconnection.commit()
return True
except mysql.connector.Error as error:
print("Failed updating MySQL table {}: {}".format(table, error))
print(traceback.format_exc())
logger.error("Failed updating MySQL table {}: {}".format(table, error))
logger.error(traceback.format_exc())
return False


Expand All @@ -506,7 +508,7 @@
try:
index = header.index(column_name)
except ValueError:
print("column_name not found")
logger.error("column_name not found")
output = list(map(lambda x: databody[x][index], range(0, len(databody))))
return output

Expand All @@ -529,7 +531,7 @@
def GetTrim(self, serialNumber, debug=False):
connection = self.connection
if connection == "Offline" or connection == []:
print("DB is offline")
logger.error("DB is offline")
return [], []
connection.connect()
cursor = connection.cursor()
Expand All @@ -547,7 +549,7 @@
)
results = cursor.fetchall() # [('TFPX CROC 1x2 HPK sensor module',)]
if debug:
print("raw description" + str(results))
logger.debug("raw description" + str(results))

if "sensor" in str(results[0][0]):
cursor.execute(
Expand All @@ -556,8 +558,8 @@
chipSensorResult = cursor.fetchall()
secondParent = chipSensorResult[0][0]
if debug:
print("it is sensor module")
print("secondParent" + str(secondParent))
logger.debug("it is sensor module")
logger.debug("secondParent" + str(secondParent))
parenetNum = secondParent

# get VDDA value
Expand All @@ -572,7 +574,7 @@
VDDAList.append([siteNum, VDDA])
sorted_VDDAlist = sorted(VDDAList, key=lambda x: x[0])
if debug:
print("sorted_VDDAlist:" + str(sorted_VDDAlist))
logger.debug("sorted_VDDAlist:" + str(sorted_VDDAlist))

VDDDList = []
cursor.execute(
Expand All @@ -588,7 +590,7 @@
VDDDList, key=lambda x: x[0]
) # make sure the we can get VDDD value base on the order of rising chip no
if debug:
print("sorted_VDDDlist:" + str(sorted_VDDDlist))
logger.debug("sorted_VDDDlist:" + str(sorted_VDDDlist))
connection.close()
return sorted_VDDAlist, sorted_VDDDlist

Expand Down
Loading
Loading