Skip to content

Commit

Permalink
Capture errors with reading/writing files, just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
benrugg committed Dec 2, 2022
1 parent d17856b commit a0cd9a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "AI Render - Stable Diffusion in Blender",
"description": "Create amazing images using Stable Diffusion AI",
"author": "Ben Rugg",
"version": (0, 6, 5),
"version": (0, 6, 6),
"blender": (3, 0, 0),
"location": "Render Properties > AI Render",
"warning": "",
Expand Down
23 changes: 15 additions & 8 deletions analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ def init_analytics(bl_info):


def get_stored_client_id():
file_path = os.path.join(os.path.dirname(__file__), CLIENT_ID_FILENAME)
if os.path.exists(file_path):
with open(file_path, "r") as f:
return f.read()
else:
try:
file_path = os.path.join(os.path.dirname(__file__), CLIENT_ID_FILENAME)
if os.path.exists(file_path):
with open(file_path, "r") as f:
return f.read()
else:
return None
except:
print("Couldn't read file for GA")
return None


def store_client_id(client_id):
file_path = os.path.join(os.path.dirname(__file__), CLIENT_ID_FILENAME)
with open(file_path, "w") as f:
f.write(client_id)
try:
file_path = os.path.join(os.path.dirname(__file__), CLIENT_ID_FILENAME)
with open(file_path, "w") as f:
f.write(client_id)
except:
print("Couldn't write file for GA")


def create_random_client_id():
Expand Down

0 comments on commit a0cd9a7

Please sign in to comment.