Skip to content

Commit 303780f

Browse files
morrison12Fizzadar
authored andcommitted
now without unbounded recursion
1 parent 0a37957 commit 303780f

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

src/pyinfra/api/host.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def deploy(
313313
)
314314

315315
@memoize
316-
def get_temp_directory(self):
316+
def _get_temp_directory(self):
317317
temp_directory = self.state.config.TEMP_DIR
318318

319319
if temp_directory is None:
@@ -328,6 +328,10 @@ def get_temp_directory(self):
328328

329329
return temp_directory
330330

331+
def get_temp_dir_config(self):
332+
333+
return self.state.config.TEMP_DIR or self.state.config.DEFAULT_TEMP_DIR
334+
331335
def get_temp_filename(
332336
self,
333337
hash_key: Optional[str] = None,
@@ -339,7 +343,7 @@ def get_temp_filename(
339343
Generate a temporary filename for this deploy.
340344
"""
341345

342-
temp_directory = temp_directory or self.get_temp_directory()
346+
temp_directory = temp_directory or self._get_temp_directory()
343347

344348
if not hash_key:
345349
hash_key = str(uuid4())

src/pyinfra/connectors/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _ensure_sudo_askpass_set_for_host(host: "Host"):
265265
if host.connector_data.get("sudo_askpass_path"):
266266
return
267267
_, output = host.run_shell_command(
268-
SUDO_ASKPASS_COMMAND.format(host.get_temp_directory(), SUDO_ASKPASS_ENV_VAR)
268+
SUDO_ASKPASS_COMMAND.format(host.get_temp_dir_config(), SUDO_ASKPASS_ENV_VAR)
269269
)
270270
host.connector_data["sudo_askpass_path"] = shlex.quote(output.stdout_lines[0])
271271

src/pyinfra/operations/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ def block(
18031803
current = host.get_fact(Block, path=path, marker=marker, begin=begin, end=end)
18041804
cmd = None
18051805

1806-
tmp_dir = host.get_temp_directory()
1806+
tmp_dir = host.get_temp_dir_config()
18071807

18081808
# standard awk doesn't have an "in-place edit" option so we write to a tempfile and
18091809
# if edits were successful move to dest i.e. we do: <out_prep> ... do some work ... <real_out>

tests/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def get_file(
198198
):
199199
return True
200200

201-
def get_temp_directory(*args, **kwargs):
201+
def get_temp_dir_config(*args, **kwargs):
202202
return "_tempdir_"
203203

204204
@staticmethod

0 commit comments

Comments
 (0)