pxe: add try-exception for writing fallback path
This commit is contained in:
parent
69795dbf1e
commit
460a7c17cf
|
@ -266,6 +266,7 @@ def save_snapshot_in_disk(snapshot, path):
|
|||
f.write(json.dumps(snapshot))
|
||||
print(f"workbench: INFO: Snapshot written in path '{filename}'")
|
||||
except Exception as e:
|
||||
try:
|
||||
print(f"workbench: WARNING: Failed to write in snapshots directory: {e}. Attempting to save in actual path.")
|
||||
fallback_filename = "{}/{}_{}.json".format(
|
||||
path,
|
||||
|
@ -274,6 +275,8 @@ def save_snapshot_in_disk(snapshot, path):
|
|||
with open(fallback_filename, "w") as f:
|
||||
f.write(json.dumps(snapshot))
|
||||
print(f"workbench: INFO: Snapshot written in fallback path '{fallback_filename}'")
|
||||
except Exception as e:
|
||||
print(f"workbench: ERROR: Failed to write in fallback path: {fallback_error}. Could not save snapshot locally.")
|
||||
|
||||
# TODO sanitize url, if url is like this, it fails
|
||||
# url = 'http://127.0.0.1:8000/api/snapshot/'
|
||||
|
|
Loading…
Reference in a new issue