Skip to content

Commit c35e7a0

Browse files
committed
Fix for read-only json files.
1 parent 4c451f8 commit c35e7a0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

BEngine-Py/bengine/BERunNodes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def MakeInputsJS(node_tree):
8383
def SaveBlenderInputs(be_base_stuff: BEUtils.BaseStuff, node_tree):
8484
js_output_data = MakeInputsJS(node_tree)
8585

86-
# If No JSON File
8786
gn_js_path = be_base_stuff.blendfolder + be_base_stuff.blendfile_name + '_' + be_base_stuff.node_sys_name + '.json'
8887

8988
print("JSON Path to Save: " + gn_js_path)

BEngine-Py/bengine/Utils/BEUtils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
import stat
13
import bpy
24

35
import json
@@ -27,8 +29,14 @@ def LoadJSON(bengineInputs_path: str):
2729

2830

2931
def SaveJSON(gn_js_path, js_data):
30-
with open(gn_js_path, 'w') as json_file:
3132

33+
# Set Writable
34+
if os.path.exists(gn_js_path) and not os.access(gn_js_path, os.W_OK):
35+
os.chmod(gn_js_path, stat.S_IWRITE)
36+
print("File Was Read-Only and Has Been Changed: " + gn_js_path)
37+
38+
# Save JSON
39+
with open(gn_js_path, 'w') as json_file:
3240
json.dump(js_data, json_file)
3341

3442

0 commit comments

Comments
 (0)