Merge branch 'carbon' into 'develop'

No conflicts.
This commit is contained in:
rallytime 2016-09-19 11:21:02 -06:00
commit bdb15217d3
5 changed files with 27 additions and 28 deletions

View File

@ -262,7 +262,6 @@ import pipes
import re
import shutil
import string
import sys
import time
import uuid
import base64
@ -271,10 +270,10 @@ import subprocess
# Import Salt libs
from salt.exceptions import CommandExecutionError, SaltInvocationError
import salt.ext.six as six
from salt.ext.six.moves import map # pylint: disable=import-error,redefined-builtin
from salt.utils.decorators \
import identical_signature_wrapper as _mimic_signature
import salt.utils
import salt.utils.decorators
import salt.utils.thin
import salt.pillar
import salt.exceptions
@ -283,10 +282,6 @@ import salt.fileclient
from salt.state import HighState
import salt.client.ssh.state
# Import 3rd-party libs
import salt.ext.six as six
# pylint: disable=import-error
try:
import docker
@ -296,8 +291,7 @@ except ImportError:
HAS_DOCKER_PY = False
try:
PY_VERSION = sys.version_info[0]
if PY_VERSION == 2:
if six.PY2:
import backports.lzma as lzma
else:
import lzma
@ -627,7 +621,7 @@ class _api_version(object):
.format(self.api_version, current_api_version)
)
return func(*args, **salt.utils.clean_kwargs(**kwargs))
return _mimic_signature(func, wrapper)
return salt.utils.decorators.identical_signature_wrapper(func, wrapper)
class _client_version(object):
@ -656,7 +650,7 @@ class _client_version(object):
' `docker.version` = "{0}"'.format(minion_conf))
raise CommandExecutionError(error_message)
return func(*args, **salt.utils.clean_kwargs(**kwargs))
return _mimic_signature(func, wrapper)
return salt.utils.decorators.identical_signature_wrapper(func, wrapper)
def _docker_client(wrapped):

View File

@ -31,6 +31,7 @@ except ImportError:
# Import salt libs
import salt.utils
import salt.utils.locales
import salt.ext.six as six
# Set up logging
log = logging.getLogger(__name__)
@ -354,7 +355,7 @@ def set_computer_name(name):
salt 'minion-id' system.set_computer_name 'DavesComputer'
'''
if name and not isinstance(name, str):
if name and six.PY2:
name = name.decode('utf-8')
if windll.kernel32.SetComputerNameExW(win32con.ComputerNamePhysicalDnsHostname,

View File

@ -12,25 +12,26 @@ This tool is accessed using `salt-extend`
:codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`
'''
# Import Python libs
from __future__ import absolute_import
from __future__ import print_function
from datetime import date
import logging
import tempfile
import os
import sys
import shutil
from jinja2 import Template
# zip compat for PY2/3
# Import Salt libs
from salt.serializers.yaml import deserialize
from salt.ext.six.moves import zip
from salt.utils import fopen
from salt.utils.odict import OrderedDict
import salt.utils
import salt.version
import logging
log = logging.getLogger(__name__)
try:
@ -55,7 +56,7 @@ def _get_template(path, option_key):
:returns: Details about the template
:rtype: ``tuple``
'''
with fopen(path, "r") as template_f:
with salt.utils.fopen(path, "r") as template_f:
template = deserialize(template_f)
info = (option_key, template.get('description', ''), template)
return info
@ -137,10 +138,10 @@ def _mergetreejinja(src, dst, context):
if item != TEMPLATE_FILE_NAME:
d = Template(d).render(context)
log.info("Copying file {0} to {1}".format(s, d))
with fopen(s, 'r') as source_file:
with salt.utils.fopen(s, 'r') as source_file:
src_contents = source_file.read()
dest_contents = Template(src_contents).render(context)
with fopen(d, 'w') as dest_file:
with salt.utils.fopen(d, 'w') as dest_file:
dest_file.write(dest_contents)
@ -300,7 +301,7 @@ def run(extension=None, name=None, description=None, salt_dir=None, merge=False,
_mergetree(temp_dir, salt_dir)
path = salt_dir
print('New module stored in {0}'.format(path))
log.info('New module stored in {0}'.format(path))
return path
if __name__ == '__main__':

View File

@ -270,14 +270,17 @@ def get_unused_localhost_port():
usock.close()
return port
if sys.platform.startswith('darwin') and port in _RUNTESTS_PORTS:
DARWIN = True if sys.platform.startswith('darwin') else False
BSD = True if 'bsd' in sys.platform else False
if DARWIN and port in _RUNTESTS_PORTS:
port = get_unused_localhost_port()
usock.close()
return port
_RUNTESTS_PORTS[port] = usock
if sys.platform.startswith('darwin'):
if DARWIN or BSD:
usock.close()
return port

View File

@ -13,11 +13,6 @@ import os
import shutil
from datetime import date
# Import salt libs
import salt.utils.extend
from salt.utils import fopen
import integration
# Import Salt Testing libs
from salttesting import TestCase
from salttesting.helpers import ensure_in_syspath
@ -25,6 +20,11 @@ from salttesting.mock import MagicMock, patch
ensure_in_syspath('../../')
# Import salt libs
import salt.utils.extend
import integration
import salt.utils
class ExtendTestCase(TestCase):
def setUp(self):
@ -44,7 +44,7 @@ class ExtendTestCase(TestCase):
self.assertFalse(os.path.exists(os.path.join(out, 'template.yml')))
self.assertTrue(os.path.exists(os.path.join(out, 'directory')))
self.assertTrue(os.path.exists(os.path.join(out, 'directory', 'test.py')))
with fopen(os.path.join(out, 'directory', 'test.py'), 'r') as test_f:
with salt.utils.fopen(os.path.join(out, 'directory', 'test.py'), 'r') as test_f:
self.assertEqual(test_f.read(), year)
if __name__ == '__main__':