Skip to content

Commit

Permalink
Append pid to temp file.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabdi-noaa committed Jun 8, 2022
1 parent a552ef9 commit b7dde4a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ush/python_utils/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ def load_shell_as_ini_config(file_name, return_string=True):
cfg = cfg.replace("\\\n"," ")

# write content to temp file and load it as ini
temp_file = os.path.join(os.getcwd(), "_temp_conf.ini")
temp_file = os.path.join(os.getcwd(), "_temp." + str(os.getpid()) + ".ini")
with open(temp_file,"w") as file:
file.write(cfg)
cfg = load_ini_config(temp_file, return_string)
os.remove(temp_file)

# load it as a structured ini file
try:
cfg = load_ini_config(temp_file, return_string)
finally:
os.remove(temp_file)

return cfg

Expand Down

0 comments on commit b7dde4a

Please sign in to comment.