Skip to content

Commit

Permalink
Use a local compat module instead of cloudify._compat (#77)
Browse files Browse the repository at this point in the history
Just for a 20 line compat module it's not really worth it
to require a 5.1 common

This just happens to allow the plugin to work with a 5.0.5
manager as well

Co-authored-by: Łukasz Maksymczuk <[email protected]>
  • Loading branch information
tehasdf and Łukasz Maksymczuk authored May 10, 2020
1 parent f284266 commit a4a11af
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
40 changes: 40 additions & 0 deletions fabric_plugin/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
########
# Copyright (c) 2019 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.

"""Python 2 + 3 compatibility utils"""
# flake8: noqa

import sys
PY2 = sys.version_info[0] == 2


if PY2:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
exec("""
def exec_(code, globs):
exec code in globs
""")

else:
from io import StringIO
exec_ = getattr(builtins, 'exec')


__all__ = [
'StringIO', 'exec_'
]
2 changes: 1 addition & 1 deletion fabric_plugin/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
from cloudify import ctx
from cloudify import utils
from cloudify import exceptions
from cloudify._compat import exec_, StringIO
from cloudify.decorators import operation
from cloudify.proxy.client import CTX_SOCKET_URL
from cloudify.proxy import client as proxy_client
from cloudify.proxy import server as proxy_server
from cloudify.exceptions import NonRecoverableError

from fabric_plugin import exec_env
from fabric_plugin._compat import exec_, StringIO

from cloudify.proxy.client import ScriptException

Expand Down
2 changes: 1 addition & 1 deletion fabric_plugin/tests/test_fabric_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
from mock import patch, MagicMock, Mock

from cloudify import ctx
from cloudify._compat import StringIO
from cloudify.workflows import local
from cloudify.decorators import workflow
from cloudify.endpoint import LocalEndpoint
from cloudify.workflows import ctx as workflow_ctx
from cloudify.exceptions import NonRecoverableError

from fabric_plugin import tasks
from fabric_plugin._compat import StringIO


class BaseFabricPluginTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='cloudify-fabric-plugin',
version='2.0.1',
version='2.0.2',
author='Cloudify',
author_email='[email protected]',
packages=['fabric_plugin'],
Expand Down

0 comments on commit a4a11af

Please sign in to comment.