def _ParseGraphJson(self, json_data): if not self._chart and not self._trace_or_story: return [] if self._chart not in json_data: raise errors.ReadValueChartNotFound(self._chart) if self._trace_or_story not in json_data[self._chart]['traces']: raise errors.ReadValueTraceNotFound(self._trace_or_story) return [ float(json_data[self._chart]['traces'][self._trace_or_story][0]) ]
def _Poll(self): graphjson = RetrieveOutputJson( self._isolate_server, self._isolate_hash, self._results_filename) if not self._chart and not self._trace: self._Complete(result_values=tuple([])) return if self._chart not in graphjson: raise errors.ReadValueChartNotFound(self._chart) if self._trace not in graphjson[self._chart]['traces']: raise errors.ReadValueTraceNotFound(self._trace) result_value = float(graphjson[self._chart]['traces'][self._trace][0]) self._Complete(result_values=(result_value,))
def HandleGraphJson(self, task, data): chart = task.payload.get('graph_json_options', {}).get('chart', '') trace = task.payload.get('graph_json_options', {}).get('trace', '') if not chart and not trace: task.payload.update({ 'result_values': [], 'tries': task.payload.get('tries', 0) + 1 }) return [CompleteReadValueAction(self.job, task, 'completed')] if chart not in data: raise errors.ReadValueChartNotFound(chart) if trace not in data[chart]['traces']: raise errors.ReadValueTraceNotFound(trace) task.payload.update({ 'result_values': [float(data[chart]['traces'][trace][0])], 'tries': task.payload.get('tries', 0) + 1 }) return [CompleteReadValueAction(self.job, task, 'completed')]