|
64 | 64 | warnings.simplefilter(action='ignore', category=FutureWarning) |
65 | 65 |
|
66 | 66 |
|
| 67 | +class syntheticMaintPValidate: |
| 68 | + def __init__(self, name, description): |
| 69 | + self.name = name |
| 70 | + self.description = description |
| 71 | + self.reason = "" |
| 72 | + self.criticality = "critical" |
| 73 | + self.passed = True |
| 74 | + self.recommended_action = "" |
| 75 | + self.sub_reason = "" |
| 76 | + self.showValidation = True |
| 77 | + self.failureDetails = self.initFailureDetails() |
| 78 | + |
| 79 | + def initFailureDetails(self): |
| 80 | + failure_details = {} |
| 81 | + failure_details["fail_type"] = "" |
| 82 | + failure_details["header"] = "" |
| 83 | + failure_details["footer"] = "" |
| 84 | + failure_details["column"] = [] |
| 85 | + failure_details["row"] = [] |
| 86 | + return failure_details |
| 87 | + |
| 88 | + def updateFailureDetails(self, result, recommended_action, reason, header, footer, column, row): |
| 89 | + self.recommended_action = recommended_action |
| 90 | + self.reason = reason |
| 91 | + self.passed = False |
| 92 | + self.failureDetails["fail_type"] = result |
| 93 | + self.failureDetails["header"] = header |
| 94 | + self.failureDetails["footer"] = footer |
| 95 | + self.failureDetails["column"] = column |
| 96 | + self.failureDetails["row"] = row |
| 97 | + |
| 98 | + def buildResult(self): |
| 99 | + result = { |
| 100 | + "syntheticMaintPValidate": { |
| 101 | + "attributes": { |
| 102 | + "name": self.name, |
| 103 | + "description": self.description, |
| 104 | + "reason": self.reason, |
| 105 | + "criticality": self.criticality, |
| 106 | + "passed": self.passed, |
| 107 | + "recommended_action": self.recommended_action, |
| 108 | + "sub_reason": self.sub_reason, |
| 109 | + "showValidation": self.showValidation, |
| 110 | + "failureDetails": self.failureDetails |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + return result |
| 115 | + |
| 116 | + def writeResult(self): |
| 117 | + """ |
| 118 | + Write the results of the syntheticMaintPValidate object to a file. |
| 119 | + :return: None |
| 120 | + """ |
| 121 | + filename = self.name + '.json' |
| 122 | + path = "cx-preupgrade-validation-results" |
| 123 | + if not os.path.isdir(path): |
| 124 | + os.mkdir(path) |
| 125 | + with open(os.path.join(f'{path}', filename), "w") as f: |
| 126 | + json.dump(self.buildResult(), f, indent=4) |
| 127 | + #f.write(self.buildResult()) |
| 128 | + |
| 129 | + |
67 | 130 | class OldVerClassNotFound(Exception): |
68 | 131 | """ Later versions of ACI can have class properties not found in older versions """ |
69 | 132 | pass |
@@ -1032,6 +1095,13 @@ def print_result(title, result, msg='', |
1032 | 1095 | recommended_action='', |
1033 | 1096 | doc_url='', |
1034 | 1097 | adjust_title=False): |
| 1098 | + synth = syntheticMaintPValidate(title, "") |
| 1099 | + if result in [FAIL_O, FAIL_UF, ERROR, MANUAL, POST]: |
| 1100 | + # TODO: deal with unformatted data and headers |
| 1101 | + synth.updateFailureDetails( |
| 1102 | + result=result, recommended_action=recommended_action, reason=msg, header="", footer=doc_url, column=headers, row=data |
| 1103 | + ) |
| 1104 | + synth.writeResult() |
1035 | 1105 | padding = 120 - len(title) - len(msg) |
1036 | 1106 | if adjust_title: padding += len(title) + 18 |
1037 | 1107 | output = '{}{:>{}}'.format(msg, result, padding) |
|
0 commit comments