Use the six library for compatability
Replace dict.iteritems() with six.iteritems(dict) Import six for StringIO Import urlutils for urlencode Partial implement: blueprint py33-support Change-Id: Ieae1299915168ef10ff54e0a9e9a346350e9d1fb
This commit is contained in:
@@ -18,6 +18,7 @@ Base utilities to build API operation managers and objects on top of.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
# Python 2.4 compat
|
# Python 2.4 compat
|
||||||
@@ -86,7 +87,7 @@ class Resource(object):
|
|||||||
self._loaded = loaded
|
self._loaded = loaded
|
||||||
|
|
||||||
def _add_details(self, info):
|
def _add_details(self, info):
|
||||||
for (k, v) in info.iteritems():
|
for (k, v) in six.iteritems(info):
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def __getattr__(self, k):
|
def __getattr__(self, k):
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import cStringIO
|
|
||||||
import httplib2
|
import httplib2
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
import yaml
|
import yaml
|
||||||
@@ -64,7 +64,7 @@ class TestCase(testtools.TestCase):
|
|||||||
def shell_error(self, argstr, error_match):
|
def shell_error(self, argstr, error_match):
|
||||||
orig = sys.stderr
|
orig = sys.stderr
|
||||||
try:
|
try:
|
||||||
sys.stderr = cStringIO.StringIO()
|
sys.stderr = six.StringIO()
|
||||||
_shell = heatclient.shell.HeatShell()
|
_shell = heatclient.shell.HeatShell()
|
||||||
_shell.main(argstr.split())
|
_shell.main(argstr.split())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -224,7 +224,7 @@ class ShellTest(TestCase):
|
|||||||
def shell(self, argstr):
|
def shell(self, argstr):
|
||||||
orig = sys.stdout
|
orig = sys.stdout
|
||||||
try:
|
try:
|
||||||
sys.stdout = cStringIO.StringIO()
|
sys.stdout = six.StringIO()
|
||||||
_shell = heatclient.shell.HeatShell()
|
_shell = heatclient.shell.HeatShell()
|
||||||
_shell.main(argstr.split())
|
_shell.main(argstr.split())
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
@@ -654,7 +654,7 @@ class ShellEnvironmentTest(TestCase):
|
|||||||
fields = {'files': {}}
|
fields = {'files': {}}
|
||||||
if url:
|
if url:
|
||||||
self.m.StubOutWithMock(urllib2, 'urlopen')
|
self.m.StubOutWithMock(urllib2, 'urlopen')
|
||||||
urllib2.urlopen(url).AndReturn(cStringIO.StringIO(content))
|
urllib2.urlopen(url).AndReturn(six.StringIO(content))
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
v1shell._resolve_environment_urls(fields, env_base_url, jenv)
|
v1shell._resolve_environment_urls(fields, env_base_url, jenv)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import urllib
|
from heatclient.openstack.common.py3kcompat import urlutils
|
||||||
|
|
||||||
from heatclient.common import base
|
from heatclient.common import base
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class StackManager(base.Manager):
|
|||||||
absolute_limit = kwargs.get('limit')
|
absolute_limit = kwargs.get('limit')
|
||||||
|
|
||||||
def paginate(qp, seen=0):
|
def paginate(qp, seen=0):
|
||||||
url = '/stacks?%s' % urllib.urlencode(qp)
|
url = '/stacks?%s' % urlutils.urlencode(qp)
|
||||||
|
|
||||||
stacks = self._list(url, "stacks")
|
stacks = self._list(url, "stacks")
|
||||||
for stack in stacks:
|
for stack in stacks:
|
||||||
|
|||||||
Reference in New Issue
Block a user