Merge "Add support for Python 3"

This commit is contained in:
Jenkins 2014-09-02 10:17:38 +00:00 committed by Gerrit Code Review
commit 7d61ca940c
12 changed files with 20 additions and 20 deletions

View File

@ -49,7 +49,7 @@ def store(name, content):
with tempfile.NamedTemporaryFile(
dir=cfg.CONF.cachedir,
delete=False) as new:
new.write(json.dumps(content, indent=1))
new.write(json.dumps(content, indent=1).encode('utf-8'))
new.flush()
if not os.path.exists(orig_path):
shutil.copy(new.name, orig_path)
@ -80,6 +80,6 @@ def store_meta_list(name, data_keys):
with tempfile.NamedTemporaryFile(prefix='tmp_meta_list.',
dir=os.path.dirname(dest),
delete=False) as out:
out.write(json.dumps(final_list))
out.write(json.dumps(final_list).encode('utf-8'))
os.rename(out.name, dest)
return dest

View File

@ -19,11 +19,11 @@ import os
from keystoneclient.contrib.ec2 import utils as ec2_utils
from lxml import etree
from oslo.config import cfg
import urlparse
import six.moves.urllib.parse as urlparse
from openstack.common import log
from os_collect_config import common
from os_collect_config import exc
from os_collect_config.openstack.common import log
CONF = cfg.CONF
logger = log.getLogger(__name__)

View File

@ -22,7 +22,6 @@ import subprocess
import sys
import time
from openstack.common import log
from os_collect_config import cache
from os_collect_config import cfn
from os_collect_config import ec2
@ -31,6 +30,7 @@ from os_collect_config import heat
from os_collect_config import heat_local
from os_collect_config import keystone
from os_collect_config import local
from os_collect_config.openstack.common import log
from os_collect_config import version
from oslo.config import cfg
@ -193,7 +193,7 @@ def getfilehash(files):
try:
with open(filename) as fp:
data = fp.read()
m.update(data)
m.update(data.encode('utf-8'))
except IOError:
pass
return m.hexdigest()

View File

@ -15,9 +15,9 @@
from oslo.config import cfg
from openstack.common import log
from os_collect_config import common
from os_collect_config import exc
from os_collect_config.openstack.common import log
EC2_METADATA_URL = 'http://169.254.169.254/latest/meta-data'
CONF = cfg.CONF

View File

@ -16,9 +16,9 @@ from heatclient import client as heatclient
from keystoneclient.v3 import client as keystoneclient
from oslo.config import cfg
from openstack.common import log
from os_collect_config import exc
from os_collect_config import keystone
from os_collect_config.openstack.common import log
CONF = cfg.CONF
logger = log.getLogger(__name__)

View File

@ -17,8 +17,8 @@ import json
import os
from oslo.config import cfg
from openstack.common import log
from os_collect_config import exc
from os_collect_config.openstack.common import log
HEAT_METADATA_PATH = ['/var/lib/heat-cfntools/cfn-init-data']
CONF = cfg.CONF

View File

@ -69,10 +69,10 @@ class Keystone(object):
def _make_key(self, key):
m = hashlib.sha256()
m.update(self.auth_url)
m.update(self.user_id)
m.update(self.project_id)
m.update(key)
m.update(self.auth_url.encode('utf-8'))
m.update(self.user_id.encode('utf-8'))
m.update(self.project_id.encode('utf-8'))
m.update(key.encode('utf-8'))
return m.hexdigest()
@property

View File

@ -19,8 +19,8 @@ import os
from oslo.config import cfg
import stat
from openstack.common import log
from os_collect_config import exc
from os_collect_config.openstack.common import log
LOCAL_DEFAULT_PATHS = ['/var/lib/os-collect-config/local-data']
CONF = cfg.CONF
@ -89,7 +89,7 @@ class Collector(object):
# Now sort specifically by C locale
def locale_aware_by_first_item(data):
return locale.strxfrm(data[0])
save_locale = locale.getlocale(locale.LC_ALL)
save_locale = locale.getdefaultlocale()
locale.setlocale(locale.LC_ALL, 'C')
sorted_content = sorted(final_content, key=locale_aware_by_first_item)
locale.setlocale(locale.LC_ALL, save_locale)

View File

@ -15,12 +15,12 @@
import json
import tempfile
import urlparse
import fixtures
from lxml import etree
from oslo.config import cfg
import requests
import six.moves.urllib.parse as urlparse
import testtools
from testtools import content as test_content
from testtools import matchers
@ -196,7 +196,7 @@ class TestCfnBase(testtools.TestCase):
self.log = self.useFixture(fixtures.FakeLogger())
self.useFixture(fixtures.NestedTempfile())
self.hint_file = tempfile.NamedTemporaryFile()
self.hint_file.write('http://127.0.0.1:8000')
self.hint_file.write(u'http://127.0.0.1:8000'.encode('utf-8'))
self.hint_file.flush()
self.addCleanup(self.hint_file.close)
collect.setup_conf()

View File

@ -38,7 +38,7 @@ from os_collect_config.tests import test_heat_local
def _setup_local_metadata(test_case):
test_case.useFixture(fixtures.NestedTempfile())
local_md = tempfile.NamedTemporaryFile(delete=False)
local_md.write(json.dumps(test_heat_local.META_DATA))
local_md.write(json.dumps(test_heat_local.META_DATA).encode('utf-8'))
local_md.flush()
return local_md.name

View File

@ -15,9 +15,9 @@
import fixtures
import requests
import six.moves.urllib.parse as urlparse
import testtools
from testtools import matchers
import urlparse
import uuid
from os_collect_config import collect

View File

@ -54,7 +54,7 @@ class TestHeatLocal(testtools.TestCase):
def test_collect_heat_local(self):
with tempfile.NamedTemporaryFile() as md:
md.write(json.dumps(META_DATA))
md.write(json.dumps(META_DATA).encode('utf-8'))
md.flush()
local_md = self._call_collect(md.name)