MCPcopy Create free account
hub / github.com/apache/trafficserver / write_sessions

Function write_sessions

plugins/traffic_dump/post_process.py:178–191  ·  view source on GitHub ↗

Write the JSON sessions to the given filename. Args: sessions The parsed JSON sessions to dump into filename. filename (string) The path to the file to write the parsed JSON file to. indent (int) The number of spaces per line to write to the file. A value of N

(sessions, filename, indent)

Source from the content-addressed store, hash-verified

176
177
178def write_sessions(sessions, filename, indent):
179 """ Write the JSON sessions to the given filename.
180
181 Args:
182 sessions The parsed JSON sessions to dump into filename.
183 filename (string) The path to the file to write the parsed JSON file to.
184 indent (int) The number of spaces per line to write to the file. A
185 value of None causes the whole JSON file to be written as a single line.
186 """
187 new_json = deepcopy(TEMPLATE)
188 new_json["sessions"] = deepcopy(sessions)
189 with open(filename, "w") as f:
190 json.dump(new_json, f, ensure_ascii=False, indent=indent)
191 logging.debug(f"{filename} has {len(sessions)} sessions")
192
193
194class ParseJSONError(PostProcessError):

Callers 1

readAndCombineFunction · 0.85

Calls 2

dumpMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected