Skip to content

Commit eda751f

Browse files
committed
Do not overwrite mbed_app.json if it exists
1 parent e69923c commit eda751f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mbed/mbed.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
install_requirements = True
154154
cache_repositories = True
155155

156+
mbed_app_file_name = "mbed_app.json"
157+
156158
# stores current working directory for recursive operations
157159
cwd_root = ""
158160
_cwd = os.getcwd()
@@ -226,10 +228,10 @@ def hide_progress(max_width=80):
226228

227229
def create_default_mbed_app():
228230
# Default data content
229-
data = {'target_overrides':{'K64F':{'platform.stdio-baud-rate': 9600}}}
230-
filehandler = open("mbed_app.json","w")
231-
json.dump(data, filehandler, indent=4)
232-
filehandler.close()
231+
if not os.path.exists(mbed_app_file_name):
232+
data = {'target_overrides':{'K64F':{'platform.stdio-baud-rate': 9600}}}
233+
with open(mbed_app_file_name, "w") as mbed_app_file:
234+
json.dump(data, mbed_app_file, indent=4)
233235

234236
# Process execution
235237
class ProcessException(Exception):

0 commit comments

Comments
 (0)