rchrdgwr commited on
Commit
6d01d7e
1 Parent(s): 34a1436

try except on deal delete/write

Browse files
Files changed (1) hide show
  1. 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
- if os.path.exists(file_path):
352
- os.remove(file_path)
353
- print(f"Existing file deleted: {file_path}")
354
- with open(file_path, 'w', encoding='utf-8') as md_file:
355
- md_file.write(file_content)
 
 
 
 
 
 
 
 
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