feature: workbench pxe #2
|
@ -266,14 +266,17 @@ def save_snapshot_in_disk(snapshot, path):
|
||||||
f.write(json.dumps(snapshot))
|
f.write(json.dumps(snapshot))
|
||||||
print(f"workbench: INFO: Snapshot written in path '{filename}'")
|
print(f"workbench: INFO: Snapshot written in path '{filename}'")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"workbench: WARNING: Failed to write in snapshots directory: {e}. Attempting to save in actual path.")
|
try:
|
||||||
fallback_filename = "{}/{}_{}.json".format(
|
print(f"workbench: WARNING: Failed to write in snapshots directory: {e}. Attempting to save in actual path.")
|
||||||
path,
|
fallback_filename = "{}/{}_{}.json".format(
|
||||||
datetime.now().strftime("%Y%m%d-%H_%M_%S"),
|
path,
|
||||||
snapshot['uuid'])
|
datetime.now().strftime("%Y%m%d-%H_%M_%S"),
|
||||||
|
snapshot['uuid'])
|
||||||
with open(fallback_filename, "w") as f:
|
with open(fallback_filename, "w") as f:
|
||||||
f.write(json.dumps(snapshot))
|
f.write(json.dumps(snapshot))
|
||||||
print(f"workbench: INFO: Snapshot written in fallback path '{fallback_filename}'")
|
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
|
# TODO sanitize url, if url is like this, it fails
|
||||||
# url = 'http://127.0.0.1:8000/api/snapshot/'
|
# url = 'http://127.0.0.1:8000/api/snapshot/'
|
||||||
|
|
Loading…
Reference in a new issue