MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / save_outputs

Function save_outputs

scripts/python_ui/streamlit.py:1038–1075  ·  view source on GitHub ↗

Save pattern outputs and starred outputs to files. Error handling: - Creates output directory if it doesn't exist - Handles file write permissions - Handles JSON serialization errors - Logs all errors for debugging

()

Source from the content-addressed store, hash-verified

1036
1037
1038def save_outputs():
1039 """Save pattern outputs and starred outputs to files.
1040
1041 Error handling:
1042 - Creates output directory if it doesn't exist
1043 - Handles file write permissions
1044 - Handles JSON serialization errors
1045 - Logs all errors for debugging
1046 """
1047 logger.info("Saving outputs to persistent storage")
1048 outputs_dir = get_outputs_dir()
1049
1050 output_logs_file = os.path.join(outputs_dir, "output_logs.json")
1051 starred_outputs_file = os.path.join(outputs_dir, "starred_outputs.json")
1052
1053 try:
1054 # Save output logs
1055 with open(output_logs_file, "w") as f:
1056 json.dump(st.session_state.output_logs, f, indent=2)
1057 logger.debug(f"Saved output logs to {output_logs_file}")
1058
1059 # Save starred outputs
1060 with open(starred_outputs_file, "w") as f:
1061 json.dump(st.session_state.starred_outputs, f, indent=2)
1062 logger.debug(f"Saved starred outputs to {starred_outputs_file}")
1063
1064 except PermissionError as e:
1065 error_msg = f"Permission denied when saving outputs: {str(e)}"
1066 logger.error(error_msg)
1067 st.error(error_msg)
1068 except json.JSONEncodeError as e:
1069 error_msg = f"Error encoding outputs to JSON: {str(e)}"
1070 logger.error(error_msg)
1071 st.error(error_msg)
1072 except Exception as e:
1073 error_msg = f"Unexpected error saving outputs: {str(e)}"
1074 logger.error(error_msg)
1075 st.error(error_msg)
1076
1077
1078def load_saved_outputs():

Callers 4

save_output_logFunction · 0.85
star_outputFunction · 0.85
unstar_outputFunction · 0.85
mainFunction · 0.85

Calls 1

get_outputs_dirFunction · 0.85

Tested by

no test coverage detected