-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
How to change the directory of settings.json? #2824
Comments
See #2668 |
Hmmm, I tried what #2668 mentioned as well as #715. I couldn't seem to get it working myself. According to #715, if a settings.json is located in the same directory of the .exe, it should prioritize that first. In my case it picked the ../document/settings.json right away regardless. I also tried giving the location of the directory where the settings.json should be looked for. Again, it just went straight to ../document/settings.json. Not sure how to proceed! |
I don't know if you solved the problem, but what I found is that you can either (1) Default load settings.json from Documents, (2) pass the json as a string into --settings (note you don't pass a path to a file, only the settings.json as a raw string - Edit: until #2668 is merged anyway). The option that is mentioned in #715 with default loading if settings.json is in the same directory as the exe doesnt seem to work! Therefore what I do is have a python script construct the settings json and launch my version of AirSimProject.exe: Hope this helps someone :) |
Hey! I actually was not able to solve it :( And I'm glad I'm not the only one who noticed #715 doesn't work! The python solution you mentioned sounds awesome. Do you mind showing a part of your python code that achieves this? I tried running:
in command prompt which is the basic command mentioned in #715 and which seems to be working for you as well. Unfortunately I get this error when I run it and the application opens up: Appreciate the input and help! |
Hey! Yeah I just ended up looking directly at source! I think you are very close, but are falling prey to damn escape characters on windows! You also need to escape the backslashes I think so you end up with \" for each quote mark. I basically use this class as my handler to start and close the (built/ cooked) UE4 program too: class UE_Game_Handler(object):
"""
Available Levels:
- ApartmentLevel
- BridgeLevel
- CityLevel
- TurbineLevel
"""
def __init__(self,
level:str,
executable_path:str,
settings_dict,
log=False):
self.level = level
self.executable_path = executable_path
self.settings_dict = settings_dict
self.process = None
folder_path = os.path.join(tempfile.gettempdir(), "airsim_drone")
try:
os.makedirs(folder_path)
except OSError:
if not os.path.isdir(folder_path):
raise
self.log = log
def __enter__(self):
jsonstring = json.dumps(self.settings_dict)
jsonstring = jsonstring.replace('"', '\\\"')
# logging_file = self.logging_file.replace('"', '\\\"')
self.process = subprocess.Popen(
[self.executable_path,
'-log' if self.log else '',
self.level,
'--settings', jsonstring]
)
print(f'UE4 Process {self.process.pid} Started')
return self
def __exit__(self, type, value, traceback):
if os.name == 'nt':
returncode = subprocess.call( # Kill Process on windows
['taskkill', '/F', '/T', '/PID', str(self.process.pid)]
)
else:
self.process.terminate()
returncode = self.process.wait()
print(f'UE4 Process {self.process.pid} Closed')
return False # propogate any exceptions Essentiall note the enter function where I call replace. The settings dict passed in is the exact settings dictionary - hope that helps! |
This is so helpful thank you so much!! I appreciate it :D |
Closing as #2668 is merged now. https://microsoft.github.io/AirSim/settings/#where-are-settings-stored for future readers. |
hello, i'm also doing this, can you explain how to solve this? and where can the AirSim.exe be found? |
I want to look for the settings.json file within the same folder where the unreal engine .uproject file is located rather than looking for it within ../Documents. I have been struggling trying to find the where and what to edit in the code.
Thanks!
The text was updated successfully, but these errors were encountered: