Do not save json if write permission is not set

This commit is contained in:
Benoit Suttor 2020-07-29 10:45:28 +02:00
parent c1bf8135c3
commit a242c505cc
1 changed files with 5 additions and 2 deletions

View File

@ -81,8 +81,11 @@ class Command(BaseCommand):
contents = [contents]
self.do(contents=contents)
contents = {"data": contents}
with open(path, "w") as fd:
json.dump(contents, fd, indent=4)
try:
with open(path, "w") as fd:
json.dump(contents, fd, indent=4)
except PermissionError:
pass
def info(self, *args, **kwargs):
if self.verbosity >= 1: