Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: tools/telemetry/telemetry/value/failure.py

Issue 417193005: Add Value FromDict to Telemetry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Nat's comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/value/__init__.py ('k') | tools/telemetry/telemetry/value/failure_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/value/failure.py
diff --git a/tools/telemetry/telemetry/value/failure.py b/tools/telemetry/telemetry/value/failure.py
index 252bb22f2c454e087d301513bdf611b39adc7aea..ba6998ad4b4c6c22c0c18f03ae2fb6b11c1f4779 100644
--- a/tools/telemetry/telemetry/value/failure.py
+++ b/tools/telemetry/telemetry/value/failure.py
@@ -29,10 +29,15 @@ class FailureValue(value_module.Value):
page: The page where this failure occurs.
message: A string message describing the failure.
"""
+ exc_info = cls._GetExcInfoFromMessage(message)
+ return FailureValue(page, exc_info)
+
+ @staticmethod
+ def _GetExcInfoFromMessage(message):
try:
raise Exception(message)
except Exception:
- return FailureValue(page, sys.exc_info())
+ return sys.exc_info()
def __repr__(self):
if self.page:
@@ -61,8 +66,8 @@ class FailureValue(value_module.Value):
def GetRepresentativeString(self):
return None
- @classmethod
- def GetJSONTypeName(cls):
+ @staticmethod
+ def GetJSONTypeName():
return 'failure'
def AsDict(self):
@@ -70,6 +75,19 @@ class FailureValue(value_module.Value):
d['value'] = GetStringFromExcInfo(self.exc_info)
return d
+ @staticmethod
+ def FromDict(value_dict, page_dict):
+ kwargs = value_module.Value.GetConstructorKwArgs(value_dict, page_dict)
+ del kwargs['name']
+ del kwargs['units']
+ important = kwargs.get('important', None)
+ if important != None:
+ del kwargs['important']
+ kwargs['exc_info'] = FailureValue._GetExcInfoFromMessage(
+ value_dict['value'])
+
+ return FailureValue(**kwargs)
+
@classmethod
def MergeLikeValuesFromSamePage(cls, values):
assert False, 'Should not be called.'
« no previous file with comments | « tools/telemetry/telemetry/value/__init__.py ('k') | tools/telemetry/telemetry/value/failure_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698