Skip to content

Commit

Permalink
fixed temp file path issue. Using pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
dwr-psandhu committed Nov 24, 2024
1 parent 1f58af5 commit f57a650
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dms_datastore/hrrr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,23 @@ def s3(self):
@property
def tmpdir(self):
if not hasattr(self, "_tmpdir"):
self._tmpdir = tempfile.TemporaryDirectory(dir=self.pscr)
# Convert self.pscr to Path object if it isn't already
pscr_path = pathlib.Path(self.pscr)

# Create directory if it doesn't exist
pscr_path.mkdir(parents=True, exist_ok=True)

# Create a temporary directory
self._tmpdir = tempfile.TemporaryDirectory(dir=str(pscr_path))

# Return the path as a Path object
return pathlib.Path(self._tmpdir.name)

# def tmpdir(self):
# if not hasattr(self, "_tmpdir"):
# self._tmpdir = os.makedirs(self.pscr)
# #self._tmpdir = tempfile.TemporaryDirectory(dir=self.pscr)
# return pathlib.Path(self._tmpdir.name)

@property
def files(self):
Expand Down

0 comments on commit f57a650

Please sign in to comment.