diff --git a/salt/utils/thin.py b/salt/utils/thin.py index cddad8cc57c..38d8aca2ab5 100644 --- a/salt/utils/thin.py +++ b/salt/utils/thin.py @@ -327,8 +327,10 @@ def _get_thintar_prefix(tarname): :param tarname: name of the chosen tarball :return: prefixed tarname ''' - tfd, tmp_tarname = tempfile.mkstemp(dir=os.path.dirname(tarname), prefix=".thin-", - suffix="." + os.path.basename(tarname).split(".", 1)[-1]) + tfd, tmp_tarname = tempfile.mkstemp( + dir=os.path.dirname(tarname), + prefix=".thin-", + suffix=os.path.splitext(tarname)[1]) os.close(tfd) return tmp_tarname @@ -458,7 +460,6 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', elif compress == 'zip': tfp = zipfile.ZipFile(tmp_thintar, 'w', compression=zlib and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED) tfp.add = tfp.write - try: # cwd may not exist if it was removed but salt was run from it start_dir = os.getcwd() except OSError: diff --git a/tests/unit/utils/test_thin.py b/tests/unit/utils/test_thin.py index cdef5e0cb4b..587043be80a 100644 --- a/tests/unit/utils/test_thin.py +++ b/tests/unit/utils/test_thin.py @@ -17,6 +17,7 @@ import salt.exceptions from salt.utils import thin from salt.utils import json import salt.utils.stringutils +import salt.utils.platform from salt.utils.stringutils import to_bytes as bts from salt.ext.six.moves import range @@ -423,6 +424,8 @@ class SSHThinTestCase(TestCase): self.assertIn('The minimum required python version to run salt-ssh is ' '"2.6"', str(err.value)) + @skipIf(salt.utils.platform.is_windows() and thin._six.PY2, + 'Dies on Python2 on Windows') @patch('salt.exceptions.SaltSystemExit', Exception) @patch('salt.utils.thin.log', MagicMock()) @patch('salt.utils.thin.os.makedirs', MagicMock())