Skip to content

Commit

Permalink
Merge pull request google#129 from fahhem/clean_inspector
Browse files Browse the repository at this point in the history
Cleanup outcome details in inspector output
  • Loading branch information
grybmadsci committed Feb 12, 2016
2 parents a19629c + 75d4ce6 commit 68e2d3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 6 additions & 3 deletions openhtf/io/output/mfg_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from openhtf.io.proto import units_pb2

from openhtf import util
from openhtf.exe import test_state
from openhtf.util import validators

# pylint: disable=no-member
Expand Down Expand Up @@ -69,10 +70,12 @@ def _PopulateHeader(record, testrun):
testrun.run_name = record.metadata['run_name']
for details in record.outcome_details:
testrun_code = testrun.failure_codes.add()
if ':' in details:
testrun_code.code, testrun_code.details = details.split(':', 1)
if details.code_type == test_state.TestState.State.ERROR:
testrun_code.code = details.code
testrun_code.details = details.description
else:
testrun_code.details = details
testrun_code.code = details.code_type
testrun_code.details = '%s: %s' % (details.code, details.description)


def _AttachJson(record, testrun):
Expand Down
14 changes: 8 additions & 6 deletions openhtf/io/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class InvalidMeasurementDimensions(Exception):
"""Raised when a measurement is taken with the wrong number of dimensions."""


Attachment = collections.namedtuple('Attachment', 'data mimetype')
LogRecord = collections.namedtuple(
'LogRecord', 'level logger_name source lineno timestamp_millis message')
OutcomeDetails = collections.namedtuple(
'OutcomeDetails', 'code_type code description')


class TestRecord( # pylint: disable=too-few-public-methods,no-init
mutablerecords.Record(
'TestRecord', ['dut_id', 'station_id'],
Expand All @@ -44,8 +51,7 @@ def AddOutcomeDetails(self, code_type, code, details=None):
code: A code name or number.
details: A string providing details about the outcome code.
"""
self.outcome_details.append('%s Code %s: %s' % (code_type, code,
details if details else ''))
self.outcome_details.append(OutcomeDetails(code_type, code, details or ''))


class PhaseRecord( # pylint: disable=too-few-public-methods,no-init
Expand All @@ -65,7 +71,3 @@ class PhaseRecord( # pylint: disable=too-few-public-methods,no-init
See measurements.Record.GetValues() for more information.
"""

Attachment = collections.namedtuple('Attachment', 'data mimetype')
LogRecord = collections.namedtuple('LogRecord', 'level logger_name source '
'lineno timestamp_millis message')

0 comments on commit 68e2d3f

Please sign in to comment.