Created
October 12, 2021 07:41
-
-
Save svrj/31a3557631f0f9c5d8bd6de869804975 to your computer and use it in GitHub Desktop.
Parsing/Counting FCO failures in SPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from SigmaProductionTools.utils.configuration import conf | |
| from SigmaProductionTools.utils.database import Database | |
| import pathlib | |
| def parse_result(result: dict, predicate) -> bool: | |
| text = result["text"] | |
| step_text = text.split("||") | |
| found = False | |
| for s in step_text: | |
| if predicate(s): | |
| found = True | |
| return found | |
| if __name__ == "__main__": | |
| conf["database"]["database"] = "production" | |
| db = Database() | |
| db.connect_db() | |
| query_fpath = pathlib.Path("query.txt") | |
| with query_fpath.open() as f: | |
| query = f.read() | |
| results = db._query(query) | |
| step_names = { | |
| "Please connect the Test Control Unit", | |
| "Checking Test Control Unit Connection", | |
| "Checking Bus Voltage", | |
| "Checking TA Leakage", | |
| "Checking TA Current", | |
| "Checking USB Function", | |
| "Flashing FCO Test Firmware", | |
| "Erasing Battery Charge MCU", | |
| "Flashing Battery Charge Test Firmware", | |
| "Checking FCO Connection", | |
| "Checking Battery Charge Connection", | |
| "Confirm that both LEDs are blinking RED-GREEN-BLUE", | |
| "Checking Pin Connections", | |
| "Checking CAN Bus Function", | |
| "Enabling Cell Test", | |
| "Checking Battery Cell Voltage Read Circuitry", | |
| "Disabling Cell Test", | |
| "Checking Cell Over-Voltage Protection", | |
| "Checking Battery Charging", | |
| "Checking FCO ADCs", | |
| "Checking ADCs and Board Voltages", | |
| "Confirm that the external capacitor is connected to the FCO test adapter", | |
| "Checking Switchover Test", | |
| "Erasing FCO", | |
| "Erasing Battery Charge MCU", | |
| } | |
| result_dict = dict() | |
| for name in step_names: | |
| def predicate(s): | |
| return name in s and "Fail" in s | |
| count = 0 | |
| for result in results: | |
| if parse_result(result, predicate): | |
| count += 1 | |
| result_dict[name] = count | |
| for name, count in sorted(result_dict.items(), key=lambda item: item[1], reverse=True): | |
| if count > 0: | |
| s = "s" if count != 1 else "" | |
| print("============================") | |
| print("Results:", "name = ", name) | |
| print("Found", count, f"failure{s}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment