Spaces:
Sleeping
Sleeping
try except on deal delete/write
Browse files- utils_opportunity_review.py +12 -5
utils_opportunity_review.py
CHANGED
@@ -348,8 +348,15 @@ def create_opportunity_review_report(structured_results):
|
|
348 |
return opportunity_review_report
|
349 |
|
350 |
def save_md_file(file_path, file_content):
|
351 |
-
|
352 |
-
os.
|
353 |
-
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
return opportunity_review_report
|
349 |
|
350 |
def save_md_file(file_path, file_content):
|
351 |
+
try:
|
352 |
+
if os.path.exists(file_path):
|
353 |
+
os.remove(file_path)
|
354 |
+
print(f"Existing file deleted: {file_path}")
|
355 |
+
|
356 |
+
with open(file_path, 'w', encoding='utf-8') as md_file:
|
357 |
+
md_file.write(file_content)
|
358 |
+
print(f"File saved successfully: {file_path}")
|
359 |
+
except PermissionError:
|
360 |
+
print(f"Permission denied when trying to delete or save file: {file_path}")
|
361 |
+
|
362 |
+
return None
|