def get_summary(measurement_id):
"""
Returns a deferred that will fire with the content of the summary
or will errback with MeasurementInProgress if the measurement has not
yet finished running.
"""
measurement_path = FilePath(config.measurements_directory)
measurement = measurement_path.child(measurement_id)
if measurement.child("measurements.njson.progress").exists():
return defer.fail(MeasurementInProgress)
summary = measurement.child("summary.json")
anomaly = measurement.child("anomaly")
if not summary.exists():
return deferToThread(
generate_summary,
measurement.child("measurements.njson").path,
summary.path,
anomaly.path
)
with summary.open("r") as f:
return defer.succeed(json.load(f))
评论列表
文章目录