def _build_record(self, nodeid, func, tcid, time_taken, comp, result=None, desc=None, rtype="Executed", index=0, syslog_count=0, fcli=0, tryssh=0, dut_list=[]): self.count[index] = self.count[index] + 1 result_def, desc_def = self.get() result = result_def if result is None else result desc = desc_def if desc is None else desc executedOn = get_timestamp(False) if comp: rcdict = { "#": self.count[index], "Feature": comp, "TestCase": tcid, "Result": result, "ExecutedOn": executedOn, "ResultType": rtype, "Description": desc, "Function": func, "Module": paths.get_mlog_basename(nodeid), "Devices": " ".join(map(str, dut_list)), } else: rcdict = { "#": self.count[index], "Module": paths.get_mlog_basename(nodeid), "TestFunction": func, "Result": result, "ExecutedOn": executedOn, "TimeTaken": time_taken, "Syslogs": syslog_count, "FCLI": fcli, "TSSH": tryssh, "DCNT": len(dut_list), "Description": desc, "Devices": " ".join(map(str, dut_list)), } return rcdict
def publish(self, nodeid, func, tcid, time_taken, comp, result=None, desc=None, rtype="Executed", syslogs=None, fcli=0, tryssh=0, dut_list=[], models=[], chips=[]): syslog_count = 0 if not syslogs else len(syslogs) index = 0 if rtype == "Executed" else 1 rcdict = self._build_record(nodeid, func, tcid, time_taken, comp, result, desc, rtype, index, syslog_count, fcli, tryssh, dut_list, models, chips) self.write_csv(rcdict, index) if not comp: index = 2 for devname, msgtype, date, host, level, text, module, msg in syslogs: func = func if func else msgtype self.count[index] = self.count[index] + 1 d = { "#": self.count[index], "Device": devname, "Module": paths.get_mlog_basename(nodeid), "TestFunction": func, "Result": rcdict["Result"], "LogDate": date, "LogHost": host, "LogLevel": level, "LogModule": module, "LogMessage": msg, "LogText": text, } if hide_log_text: d.pop("LogText") if hide_log_host: d.pop("LogHost") self.write_csv(d, index) return rcdict