Skip to content

Commit

Permalink
target: Make Target.make_temp() use Target.tmp_directory
Browse files Browse the repository at this point in the history
Also avoid a "None" prefix when no prefix is asked for, and set None as
the default prefix value.

Remove the "devlib-test" default value as make_temp() has nothing to do
with tests.
  • Loading branch information
douglas-raillard-arm committed Nov 20, 2024
1 parent 9318e96 commit 4826609
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions devlib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ async def write_value(self, path, value, verify=True, as_root=True):
raise

@asyn.asynccontextmanager
async def make_temp(self, is_directory=True, directory='', prefix='devlib-test'):
async def make_temp(self, is_directory=True, directory=None, prefix=None):
"""
Creates temporary file/folder on target and deletes it once it's done.
Expand All @@ -1214,10 +1214,11 @@ async def make_temp(self, is_directory=True, directory='', prefix='devlib-test')
:rtype: str
"""

directory = directory or self.working_directory
directory = directory or self.tmp_directory
prefix = f'{prefix}-' if prefix else ''
temp_obj = None
try:
cmd = f'mktemp -p {quote(directory)} {quote(prefix)}-XXXXXX'
cmd = f'mktemp -p {quote(directory)} {quote(prefix)}XXXXXX'
if is_directory:
cmd += ' -d'

Expand Down

0 comments on commit 4826609

Please sign in to comment.