Skip to content
Closed
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
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Description
<!-- Provide a clear and concise description of the changes in this PR. -->

## Checklist
Before submitting this PR, please ensure the following:

- [ ] I am using the **correct branches/versions** of all submodules.
- [ ] I have successfully **launched the Simplified GUI**.
- [ ] I have successfully **run a test in the Simplified GUI**.
- [ ] I have successfully **run a test in the Expert GUI**.

## Related Issues
<!-- List any related issues, e.g. "Fixes #123" or "Closes #456". -->

## Changes Made
<!-- Summarize the major changes in this PR. -->

## Testing
<!-- Describe how you tested your changes, including commands run, configurations used, etc. -->

## Additional Notes
<!-- Add any additional comments or context if needed. -->
15 changes: 15 additions & 0 deletions .github/workflows/require-checklist.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Require Checklist

on:
pull_request:
types: [opened, edited, synchronize]
issues:
types: [opened, edited, deleted]

jobs:
job1:
runs-on: ubuntu-latest
steps:
- uses: mheap/require-checklist-action@v2
with:
requireChecklist: false # If this is true and there are no checklists detected, the action will fail
15 changes: 15 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
args: "check"
src: "./Gui"
- uses: astral-sh/ruff-action@v3
with:
args: "format --check --diff"
src: "./Gui"
14 changes: 7 additions & 7 deletions Gui/GUIutils/ANSIColorText.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
ANSIColorText.py
brief Text handler for Ph2 ACF GUI
author Kai Wei
version 0.1
date 09/24/20
Support: email to [email protected]
ANSIColorText.py
brief Text handler for Ph2 ACF GUI
author Kai Wei
version 0.1
date 09/24/20
Support: email to [email protected]
"""

import tkinter as tk
import re
from Gui.python.logging_config import logger


class AnsiColorText(tk.Text):
Expand Down
188 changes: 93 additions & 95 deletions Gui/GUIutils/DBConnection.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
"""
DBConnection.py
brief Setting up connection to database
author Kai Wei
version 0.1
date 30/09/20
Support: email to [email protected]
DBConnection.py
brief Setting up connection to database
author Kai Wei
version 0.1
date 30/09/20
Support: email to [email protected]
"""

import mysql.connector
from mysql.connector import Error
import subprocess
import os
from itertools import compress

from subprocess import Popen, PIPE
from PyQt5.QtWidgets import QMessageBox
#from Gui.GUIutils.settings import *

# from Gui.GUIutils.settings import *
from Gui.GUIutils.guiUtils import (
isActive,
formatter,
)
from Gui.python.logging_config import logger
from InnerTrackerTests.TestSequences import Test_to_Ph2ACF_Map

DB_TestResult_Schema = [
Expand All @@ -30,8 +28,6 @@
# mySQL databse server as test, may need to extend to other DB format




def QtStartConnection(TryUsername, TryPassword, TryHostAddress, TryDatabase):
# For test, no connection to DB is made and output will not be registered
# if TryHostAddress == "0.0.0.0":
Expand All @@ -50,7 +46,7 @@ def QtStartConnection(TryUsername, TryPassword, TryHostAddress, TryDatabase):
host=str(TryHostAddress),
database=str(TryDatabase),
ssl_disabled=True,
connection_timeout = 5000,
connection_timeout=5000,
)
except (ValueError, RuntimeError, TypeError, NameError, mysql.connector.Error):
msg = QMessageBox()
Expand Down Expand Up @@ -103,13 +99,13 @@ def getAllTests(dbconnection):
localList = list(Test_to_Ph2ACF_Map.keys())
remoteList = [remoteList[i][0] for i in range(len(remoteList))]
for test in remoteList:
if not test in localList:
if test not in localList:
localList.append(test)
return sorted(set(localList), key=localList.index)


def retrieveAllTests(dbconnection):
if dbconnection.is_connected() == False:
if not dbconnection.is_connected():
return
cur = dbconnection.cursor()
cur.execute("SELECT * FROM calibrationlist")
Expand Down Expand Up @@ -144,9 +140,7 @@ def retrieveModuleLastTest(dbconnection, module_id):
from results_test T WHERE Module_ID = {0}
group by Module_ID
) LATEST ON T.Module_ID = LATEST.Module_ID AND T.ExecutionTime = LATEST.MaxDate
""".format(
str(module_id)
)
""".format(str(module_id))
cur = dbconnection.cursor()
cur.execute(sql_query)
return cur.fetchall()
Expand All @@ -155,9 +149,7 @@ def retrieveModuleLastTest(dbconnection, module_id):
def insertTestResult(dbconnection, record):
sql_query = """ INSERT INTO results_test ({},{},{},{},{},{})
VALUES ({},{},{},{},{},{})
""".format(
*DB_TestResult_Schema, *record
)
""".format(*DB_TestResult_Schema, *record)
cur = dbconnection.cursor()
cur.execute(sql_query)
dbconnection.commit()
Expand Down Expand Up @@ -215,7 +207,7 @@ def getLocalTests(module_id, columns=[]):

def getLocalRemoteTests(dbconnection, module_id=None, columns=[]):
if isActive(dbconnection):
if module_id == None:
if module_id is None:
remoteTests = retrieveGenericTable(
dbconnection, "module_tests", columns=columns
) # changed table name
Expand All @@ -232,7 +224,7 @@ def getLocalRemoteTests(dbconnection, module_id=None, columns=[]):
# localTests = []
try:
timeIndex = columns.index("date")
except:
except ValueError:
timeIndex = -1

if remoteTests != [] and timeIndex != -1:
Expand Down Expand Up @@ -323,7 +315,7 @@ def retrieveWithConstraint(dbconnection, table, *args, **kwargs):
values = []
columnList = []
for key, value in kwargs.items():
if key == "columns" and type(value) == type(columnList):
if key == "columns" and type(value) is type(columnList):
columnList = value
else:
values.append(value)
Expand Down Expand Up @@ -355,7 +347,7 @@ def retrieveWithConstraintSyntax(dbconnection, table, syntax, **kwargs):
try:
columnList = []
for key, value in kwargs.items():
if key == "columns" and type(value) == type(columnList):
if key == "columns" and type(value) is type(columnList):
columnList = value
if len(columnList) > 0:
sql_query = (
Expand Down Expand Up @@ -383,7 +375,7 @@ def retrieveGenericTable(dbconnection, table, **kwargs):
try:
columnList = []
for key, value in kwargs.items():
if key == "columns" and type(value) == type(columnList):
if key == "columns" and type(value) is type(columnList):
columnList = value
if len(columnList) > 0:
sql_query = (
Expand Down Expand Up @@ -501,7 +493,7 @@ def updateGenericTable(dbconnection, table, column, data, **kwargs):
def getByColumnName(column_name, header, databody):
try:
index = header.index(column_name)
except:
except ValueError:
print("column_name not found")
output = list(map(lambda x: databody[x][index], range(0, len(databody))))
return output
Expand All @@ -512,77 +504,83 @@ def getByColumnName(column_name, header, databody):
##########################################################################





##########################################################################
## Functions for getting trim value (Begin)
##########################################################################
class GetTrimClass():
def __init__(self):
self.connection = []
def get_connection(self):
return self.connection
def GetTrim(self,serialNumber,debug = False):
connection = self.connection
if connection == "Offline" or connection == []:
print("DB is offline")
return [],[]
connection.connect()
cursor = connection.cursor()
cursor.execute(f"select component.id from component where component.serial_number='{serialNumber}';")
results = cursor.fetchall()
#handle the error of can't find the data
if results == []:
return [],[]
if debug == True:
print("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))

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))
parenetNum = secondParent


#get VDDA value
VDDAList = []
cursor.execute(f"SELECT component.serial_number,component.parent,measurement.name,type,component.site,ival from component,measurements,measurement where component.parent = {parenetNum} and measurements.name=measurement.name and component.id=measurement.part_id and measurement.name='TRIM_VDDA';")
results = cursor.fetchall()
for result in results:
VDDA = result[-1]
siteNum = result[-2]
VDDAList.append([siteNum,VDDA])
sorted_VDDAlist = sorted(VDDAList, key=lambda x: x[0])
if debug == True:
print("sorted_VDDAlist:"+str(sorted_VDDAlist))



VDDDList = []
cursor.execute(f"SELECT component.serial_number,component.parent,measurement.name,type,component.site,ival from component,measurements,measurement where component.parent = {parenetNum} and measurements.name=measurement.name and component.id=measurement.part_id and measurement.name='TRIM_VDDD';")
results = cursor.fetchall()
for result in results:
VDDD = result[-1]
siteNum = result[-2]
VDDDList.append([siteNum,VDDD])

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))
connection.close()
return sorted_VDDAlist,sorted_VDDDlist
class GetTrimClass:
def __init__(self):
self.connection = []

def get_connection(self):
return self.connection

def GetTrim(self, serialNumber, debug=False):
connection = self.connection
if connection == "Offline" or connection == []:
print("DB is offline")
return [], []
connection.connect()
cursor = connection.cursor()
cursor.execute(
f"select component.id from component where component.serial_number='{serialNumber}';"
)
results = cursor.fetchall()
# handle the error of can't find the data
if results == []:
return [], []
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:
print("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:
print("it is sensor module")
print("secondParent" + str(secondParent))
parenetNum = secondParent

# get VDDA value
VDDAList = []
cursor.execute(
f"SELECT component.serial_number,component.parent,measurement.name,type,component.site,ival from component,measurements,measurement where component.parent = {parenetNum} and measurements.name=measurement.name and component.id=measurement.part_id and measurement.name='TRIM_VDDA';"
)
results = cursor.fetchall()
for result in results:
VDDA = result[-1]
siteNum = result[-2]
VDDAList.append([siteNum, VDDA])
sorted_VDDAlist = sorted(VDDAList, key=lambda x: x[0])
if debug:
print("sorted_VDDAlist:" + str(sorted_VDDAlist))

VDDDList = []
cursor.execute(
f"SELECT component.serial_number,component.parent,measurement.name,type,component.site,ival from component,measurements,measurement where component.parent = {parenetNum} and measurements.name=measurement.name and component.id=measurement.part_id and measurement.name='TRIM_VDDD';"
)
results = cursor.fetchall()
for result in results:
VDDD = result[-1]
siteNum = result[-2]
VDDDList.append([siteNum, VDDD])

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:
print("sorted_VDDDlist:" + str(sorted_VDDDlist))
connection.close()
return sorted_VDDAlist, sorted_VDDDlist


##########################################################################
## Functions for getting trim value (END)
##########################################################################


Loading