From d34b5002a853b8b8d29423a9caf8ffde139fc47b Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: May 18 2017 08:20:21 +0000 Subject: Fix bandit issue: B108:hardcoded_tmp_directory Replace hard-coded '/tmp' with tempfile.gettempdir() --- diff --git a/freshmaker/utils.py b/freshmaker/utils.py index c7c5622..12b80ff 100644 --- a/freshmaker/utils.py +++ b/freshmaker/utils.py @@ -110,9 +110,12 @@ def get_commit_hash(repo, revision='HEAD'): return _run_command(cmd, rundir=repo, return_output=True).strip() -def _run_command(command, logger=None, rundir='/tmp', output=subprocess.PIPE, error=subprocess.PIPE, env=None, return_output=False): +def _run_command(command, logger=None, rundir=None, output=subprocess.PIPE, error=subprocess.PIPE, env=None, return_output=False): """Run a command, return output if return_output is True. Error out if command exit with non-zero code.""" + if rundir is None: + rundir = tempfile.gettempdir() + if logger: logger.info("Running %s", subprocess.list2cmdline(command))