Commit 0a887f8f authored by Mayank Mittal's avatar Mayank Mittal

adds error handling in setup_vscode.py

parent ed94e762
...@@ -14,9 +14,10 @@ when the "setup_python_env.sh" is run as part of the vs-code launch configuratio ...@@ -14,9 +14,10 @@ when the "setup_python_env.sh" is run as part of the vs-code launch configuratio
import re import re
import os import os
import pathlib
ORBIT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")) ORBIT_DIR = pathlib.Path(__file__).parents[2]
"""Path to the orbit directory.""" """Path to the orbit directory."""
ISAACSIM_DIR = os.path.join(ORBIT_DIR, "_isaac_sim") ISAACSIM_DIR = os.path.join(ORBIT_DIR, "_isaac_sim")
"""Path to the isaac-sim directory.""" """Path to the isaac-sim directory."""
...@@ -24,7 +25,10 @@ ISAACSIM_DIR = os.path.join(ORBIT_DIR, "_isaac_sim") ...@@ -24,7 +25,10 @@ ISAACSIM_DIR = os.path.join(ORBIT_DIR, "_isaac_sim")
def main(): def main():
# isaac-sim settings # isaac-sim settings
isaacsim_vscode_filename = os.path.join(ISAACSIM_DIR, ".vscode/settings.json") isaacsim_vscode_filename = os.path.join(ISAACSIM_DIR, ".vscode", "settings.json")
# make sure the isaac-sim settings file exists
if not os.path.exists(isaacsim_vscode_filename):
raise FileNotFoundError(f"Could not find the isaac-sim settings file: {isaacsim_vscode_filename}")
# read the path names from the isaac-sim settings file # read the path names from the isaac-sim settings file
with open(isaacsim_vscode_filename) as f: with open(isaacsim_vscode_filename) as f:
vscode_settings = f.read() vscode_settings = f.read()
...@@ -42,8 +46,12 @@ def main(): ...@@ -42,8 +46,12 @@ def main():
# combine them into a single string # combine them into a single string
path_names = ",\n\t\t".expandtabs(4).join(path_names) path_names = ",\n\t\t".expandtabs(4).join(path_names)
# orbit template settings
orbit_vscode_template_filename = os.path.join(ORBIT_DIR, ".vscode", "tools", "settings.template.json")
# make sure the orbit template settings file exists
if not os.path.exists(orbit_vscode_template_filename):
raise FileNotFoundError(f"Could not find the orbit template settings file: {orbit_vscode_template_filename}")
# read the orbit template settings file # read the orbit template settings file
orbit_vscode_template_filename = os.path.join(ORBIT_DIR, ".vscode/tools/settings.template.json")
with open(orbit_vscode_template_filename) as f: with open(orbit_vscode_template_filename) as f:
orbit_template_settings = f.read() orbit_template_settings = f.read()
# replace the path names in the orbit settings file with the path names from the isaac-sim settings file # replace the path names in the orbit settings file with the path names from the isaac-sim settings file
...@@ -63,7 +71,7 @@ def main(): ...@@ -63,7 +71,7 @@ def main():
orbit_settings = header_message + orbit_settings orbit_settings = header_message + orbit_settings
# write the orbit settings file # write the orbit settings file
orbit_vscode_filename = os.path.join(ORBIT_DIR, ".vscode/settings.json") orbit_vscode_filename = os.path.join(ORBIT_DIR, ".vscode", "settings.json")
with open(orbit_vscode_filename, "w") as f: with open(orbit_vscode_filename, "w") as f:
f.write(orbit_settings) f.write(orbit_settings)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment