Skip to content

Commit

Permalink
Handled exception when no permission to write in folder
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Moene <[email protected]>
  • Loading branch information
victormlg committed Dec 10, 2024
1 parent 3ba4dbc commit 887a7dd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cf_remote/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ def read_file(path):


def save_file(path, data):
if "/" in path:
mkdir("/".join(path.split("/")[0:-1]))
with open(path, "w") as f:
f.write(data)
try :
if "/" in path:
mkdir("/".join(path.split("/")[0:-1]))
with open(path, "w") as f:
f.write(data)
except PermissionError:
user_error("No permission to write to '{}'.".format(path))


def pretty(data):
Expand Down

0 comments on commit 887a7dd

Please sign in to comment.