Permalink
Browse files

Fix: salt 2018.3 + py2.7/3.x compatibility

- Fixes 'Failed to load ext_pillar reclass: Item in from list not a string'
  (#27)
- Update python 2.7/3.6 compatibility
  • Loading branch information...
epcim committed Jun 18, 2018
1 parent 2652216 commit 2e01223add9afe775667954448a231f33f0c3811
Showing with 344 additions and 48 deletions.
  1. +1 −1 .travis.yml
  2. +4 −0 reclass.py
  3. +7 −4 reclass/__init__.py
  4. +5 −1 reclass/adapters/__init__.py
  5. +7 −2 reclass/adapters/ansible.py
  6. +6 −2 reclass/adapters/salt.py
  7. +4 −0 reclass/cli.py
  8. +11 −7 reclass/config.py
  9. +5 −0 reclass/constants.py
  10. +6 −6 reclass/core.py
  11. +5 −0 reclass/datatypes/__init__.py
  12. +6 −1 reclass/datatypes/applications.py
  13. +10 −0 reclass/datatypes/classes.py
  14. +5 −0 reclass/datatypes/entity.py
  15. +4 −0 reclass/datatypes/exports.py
  16. +10 −0 reclass/datatypes/parameters.py
  17. +5 −0 reclass/datatypes/tests/__init__.py
  18. +6 −0 reclass/datatypes/tests/test_applications.py
  19. +6 −0 reclass/datatypes/tests/test_classes.py
  20. +5 −0 reclass/datatypes/tests/test_entity.py
  21. +4 −0 reclass/datatypes/tests/test_exports.py
  22. +5 −0 reclass/datatypes/tests/test_parameters.py
  23. +5 −0 reclass/defaults.py
  24. +8 −6 reclass/errors.py
  25. +6 −3 reclass/output/__init__.py
  26. +6 −0 reclass/output/json_outputter.py
  27. +7 −0 reclass/output/yaml_outputter.py
  28. +9 −5 reclass/settings.py
  29. +5 −0 reclass/storage/__init__.py
  30. +6 −0 reclass/storage/common.py
  31. +8 −4 reclass/storage/loader.py
  32. +4 −0 reclass/storage/memcache_proxy.py
  33. +4 −0 reclass/storage/mixed/__init__.py
  34. +5 −0 reclass/storage/tests/__init__.py
  35. +6 −0 reclass/storage/tests/test_loader.py
  36. +6 −0 reclass/storage/tests/test_memcache_proxy.py
  37. +4 −0 reclass/storage/tests/test_yamldata.py
  38. +6 −1 reclass/storage/yaml_fs/__init__.py
  39. +6 −1 reclass/storage/yaml_fs/directory.py
  40. +4 −0 reclass/storage/yaml_git/__init__.py
  41. +5 −0 reclass/storage/yamldata.py
  42. +5 −0 reclass/tests/__init__.py
  43. +4 −0 reclass/tests/test_core.py
  44. +5 −0 reclass/utils/__init__.py
  45. +4 −0 reclass/utils/dictpath.py
  46. +5 −0 reclass/utils/tests/__init__.py
  47. +6 −1 reclass/utils/tests/test_dictpath.py
  48. +5 −0 reclass/values/__init__.py
  49. +4 −0 reclass/values/compitem.py
  50. +4 −0 reclass/values/dictitem.py
  51. +6 −2 reclass/values/invitem.py
  52. +4 −0 reclass/values/item.py
  53. +4 −0 reclass/values/listitem.py
  54. +4 −0 reclass/values/parser.py
  55. +4 −0 reclass/values/parser_funcs.py
  56. +4 −0 reclass/values/refitem.py
  57. +4 −0 reclass/values/scaitem.py
  58. +7 −0 reclass/values/tests/__init__.py
  59. +4 −0 reclass/values/tests/test_value.py
  60. +7 −1 reclass/values/value.py
  61. +4 −0 reclass/values/valuelist.py
  62. +5 −0 reclass/version.py
  63. +4 −0 run_tests.py
  64. +4 −0 setup.py
View
@@ -44,7 +44,7 @@ script:
# To test example models with kitchen:
- export PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
- kitchen list
- if [ "$PYTHON_VERSION" = "2.7" ]; then kitchen test; fi
- kitchen test
# NOTE: travis stage builds, below saved for future reference
#jobs:
View
@@ -6,6 +6,10 @@
# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import reclass.cli
reclass.cli.main()
View
@@ -6,11 +6,14 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from reclass.output import OutputLoader
from reclass.storage.loader import StorageBackendLoader
from reclass.storage.memcache_proxy import MemcacheProxy
from .output import OutputLoader
from .storage.loader import StorageBackendLoader
from .storage.memcache_proxy import MemcacheProxy
def get_storage(storage_type, nodes_uri, classes_uri, **kwargs):
storage_class = StorageBackendLoader(storage_type).load()
@@ -5,4 +5,8 @@
#
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
@@ -14,6 +14,11 @@
# The ansible adapter has received little testing and may not work at all now.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os, sys, posix, optparse
from six import iteritems
@@ -89,9 +94,9 @@ def add_ansible_options_group(parser, defaults):
data = groups
print output(data, options.output, options.pretty_print, options.no_refs)
print(output(data, options.output, options.pretty_print, options.no_refs))
except ReclassException, e:
except ReclassException as e:
e.exit_with_message(sys.stderr)
sys.exit(posix.EX_OK)
View
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os, sys, posix
@@ -122,9 +126,9 @@ def cli():
class_mappings=class_mappings,
**defaults)
print output(data, options.output, options.pretty_print, options.no_refs)
print(output(data, options.output, options.pretty_print, options.no_refs))
except ReclassException, e:
except ReclassException as e:
e.exit_with_message(sys.stderr)
sys.exit(posix.EX_OK)
View
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import sys, os, posix
View
@@ -6,13 +6,17 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import yaml, os, optparse, posix, sys
import errors
from defaults import *
from constants import MODE_NODEINFO, MODE_INVENTORY
from reclass import get_path_mangler
from . import errors, get_path_mangler
from .defaults import *
from .constants import MODE_NODEINFO, MODE_INVENTORY
def make_db_options_group(parser, defaults={}):
ret = optparse.OptionGroup(parser, 'Database options',
@@ -171,7 +175,7 @@ def get_options(name, version, description,
def vvv(msg):
#print >>sys.stderr, msg
#print(msg, file=sys.stderr)
pass
@@ -180,8 +184,8 @@ def find_and_read_configfile(filename=CONFIG_FILE_NAME,
for d in dirs:
f = os.path.join(d, filename)
if os.access(f, os.R_OK):
vvv('Using config file: {0}'.format(f))
return yaml.safe_load(file(f))
vvv('Using config file: {0}'.format(str(f)))
return yaml.safe_load(open(f))
elif os.path.isfile(f):
raise PermissionsError('cannot read %s' % f)
return {}
View
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class _Constant(object):
View
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import copy
import time
@@ -24,10 +28,6 @@
from reclass.errors import MappingFormatError, ClassNameResolveError, ClassNotFound, InvQueryClassNameResolveError, InvQueryClassNotFound, InvQueryError, InterpolationError, ResolveError
from reclass.values.parser import Parser
try:
basestring
except NameError:
basestring = str
class Core(object):
@@ -130,7 +130,7 @@ def _recurse_entity(self, entity, merge_base=None, context=None, seen=None, node
if self._cnf_r.match(klass):
if self._settings.ignore_class_notfound_warning:
# TODO, add logging handler
print >>sys.stderr, "[WARNING] Reclass class not found: '%s'. Skipped!" % klass
print("[WARNING] Reclass class not found: '%s'. Skipped!" % klass, file=sys.stderr)
continue
e.nodename = nodename
e.uri = entity.uri
@@ -151,7 +151,7 @@ def _recurse_entity(self, entity, merge_base=None, context=None, seen=None, node
def _get_automatic_parameters(self, nodename, environment):
if self._settings.automatic_parameters:
return Parameters({ '_reclass_': { 'name': { 'full': nodename, 'short': str.split(nodename, '.')[0] },
return Parameters({ '_reclass_': { 'name': { 'full': nodename, 'short': nodename.split('.')[0] },
'environment': environment } }, self._settings, '__auto__')
else:
return Parameters({}, self._settings, '')
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from .applications import Applications
from .classes import Classes
from .entity import Entity
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from .classes import Classes
@@ -61,4 +66,4 @@ def __repr__(self):
contents = self._items + \
['%s%s' % (self._negation_prefix, i) for i in self._negations]
return "%s(%r, %r)" % (self.__class__.__name__, contents,
self._negation_prefix)
str(self._negation_prefix))
@@ -6,6 +6,15 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
#try:
# from types import StringTypes
#except ImportError:
# StringTypes = (str, )
import six
import os
@@ -52,6 +61,7 @@ def merge_unique(self, iterable):
self.append_if_new(i)
def _assert_is_string(self, item):
#if not isinstance(item, StringTypes):
if not isinstance(item, six.string_types):
raise TypeError('%s instances can only contain strings, '\
'not %s' % (self.__class__.__name__, type(item)))
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from .classes import Classes
from .applications import Applications
from .exports import Exports
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import copy
@@ -7,6 +7,16 @@
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
#try:
# from types import StringTypes
#except ImportError:
# StringTypes = (str, )
import copy
import sys
import types
@@ -0,0 +1,5 @@
# -*- coding: utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
@@ -6,8 +6,14 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from reclass.datatypes import Applications, Classes
import unittest
try:
import unittest.mock as mock
except ImportError:
@@ -6,9 +6,15 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from reclass.datatypes import Classes
from reclass.datatypes.classes import INVALID_CHARACTERS_FOR_CLASSNAMES
import unittest
try:
import unittest.mock as mock
except ImportError:
@@ -6,11 +6,16 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from reclass.settings import Settings
from reclass.datatypes import Entity, Classes, Parameters, Applications, Exports
from reclass.errors import ResolveError
import unittest
try:
import unittest.mock as mock
except ImportError:
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from reclass.settings import Settings
from reclass.datatypes import Exports, Parameters
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import copy
@@ -15,6 +19,7 @@
from reclass.datatypes import Parameters
from reclass.errors import InfiniteRecursionError, InterpolationError, ResolveError, ResolveErrorList
import unittest
try:
import unittest.mock as mock
except ImportError:
View
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os, sys
from .version import RECLASS_NAME
Oops, something went wrong.

0 comments on commit 2e01223

Please sign in to comment.