Add Python 3.x support

Implements: blueprint python3

Change-Id: I1e02568907aa38dd0efcb428235004ce47d73af8
This commit is contained in:
Michal Rostecki 2015-11-16 09:20:26 +01:00
parent ac0442a880
commit eb0d0cdc9e
3 changed files with 14 additions and 13 deletions

View File

@ -15,13 +15,11 @@
# TODO(jpeeler): Add clean up handler for SIGINT # TODO(jpeeler): Add clean up handler for SIGINT
import argparse import argparse
import ConfigParser
import datetime import datetime
import json import json
import logging import logging
import os import os
import platform import platform
import Queue
import re import re
import requests import requests
import shutil import shutil
@ -36,6 +34,7 @@ import docker
import git import git
import jinja2 import jinja2
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
import six
logging.basicConfig() logging.basicConfig()
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -168,7 +167,7 @@ class WorkerThread(Thread):
rm=True, rm=True,
pull=pull, pull=pull,
forcerm=self.forcerm): forcerm=self.forcerm):
stream = json.loads(response) stream = json.loads(response.decode('utf-8'))
if 'stream' in stream: if 'stream' in stream:
image['logs'] = image['logs'] + stream['stream'] image['logs'] = image['logs'] + stream['stream']
@ -348,7 +347,7 @@ class KollaWorker(object):
self.include_footer = config['include_footer'] self.include_footer = config['include_footer']
self.regex = config['regex'] self.regex = config['regex']
self.profile = config['profile'] self.profile = config['profile']
self.source_location = ConfigParser.SafeConfigParser() self.source_location = six.moves.configparser.SafeConfigParser()
self.source_location.read(find_config_file('kolla-build.conf')) self.source_location.read(find_config_file('kolla-build.conf'))
self.image_statuses_bad = dict() self.image_statuses_bad = dict()
self.image_statuses_good = dict() self.image_statuses_good = dict()
@ -423,10 +422,10 @@ class KollaWorker(object):
filter_ += self.source_location.get('profiles', filter_ += self.source_location.get('profiles',
profile profile
).split(',') ).split(',')
except ConfigParser.NoSectionError: except six.moves.configparser.NoSectionError:
LOG.error('No [profiles] section found in {}'.format( LOG.error('No [profiles] section found in {}'.format(
find_config_file('kolla-build.conf'))) find_config_file('kolla-build.conf')))
except ConfigParser.NoOptionError: except six.moves.configparser.NoOptionError:
LOG.error('No profile named "{}" found in {}'.format( LOG.error('No profile named "{}" found in {}'.format(
self.profile, self.profile,
find_config_file('kolla-build.conf'))) find_config_file('kolla-build.conf')))
@ -472,7 +471,7 @@ class KollaWorker(object):
if self.image_statuses_bad: if self.image_statuses_bad:
LOG.info("Images that failed to build") LOG.info("Images that failed to build")
LOG.info("===========================") LOG.info("===========================")
for name, status in self.image_statuses_bad.iteritems(): for name, status in six.iteritems(self.image_statuses_bad):
LOG.error('{}\r\t\t\t Failed with status: {}'.format( LOG.error('{}\r\t\t\t Failed with status: {}'.format(
name, status)) name, status))
@ -529,7 +528,7 @@ class KollaWorker(object):
self.source_location.get(image['name'], self.source_location.get(image['name'],
'reference') 'reference')
except ConfigParser.NoSectionError: except six.moves.configparser.NoSectionError:
LOG.debug('{}:No source location found'.format( LOG.debug('{}:No source location found'.format(
image['name'])) image['name']))
pass pass
@ -543,7 +542,7 @@ class KollaWorker(object):
for image in self.images: for image in self.images:
sort_images[image['fullname']] = image sort_images[image['fullname']] = image
for parent_name, parent in sort_images.iteritems(): for parent_name, parent in six.iteritems(sort_images):
for image in sort_images.values(): for image in sort_images.values():
if image['parent_name'] == parent_name: if image['parent_name'] == parent_name:
parent['children'].append(image) parent['children'].append(image)
@ -559,7 +558,7 @@ class KollaWorker(object):
self.find_parents() self.find_parents()
self.filter_images() self.filter_images()
queue = Queue.Queue() queue = six.moves.queue.Queue()
for image in self.images: for image in self.images:
if image['parent'] is None: if image['parent'] is None:
@ -587,7 +586,7 @@ def push_image(image):
def main(): def main():
build_config = ConfigParser.SafeConfigParser() build_config = six.moves.configparser.SafeConfigParser()
build_config.read(find_config_file('kolla-build.conf')) build_config.read(find_config_file('kolla-build.conf'))
config = merge_args_and_config(build_config) config = merge_args_and_config(build_config)
if config['debug']: if config['debug']:
@ -608,7 +607,7 @@ def main():
queue = kolla.build_queue() queue = kolla.build_queue()
for x in xrange(config['threads']): for x in six.moves.xrange(config['threads']):
worker = WorkerThread(queue, config) worker = WorkerThread(queue, config)
worker.setDaemon(True) worker.setDaemon(True)
worker.start() worker.start()

View File

@ -6,3 +6,4 @@ docker-py>=1.4.0 # Apache-2.0
Jinja2>=2.6 # BSD License (3 clause) Jinja2>=2.6 # BSD License (3 clause)
gitdb>=0.6.4 # BSD License (3 clause) gitdb>=0.6.4 # BSD License (3 clause)
GitPython>=1.0.1 # BSD License (3 clause) GitPython>=1.0.1 # BSD License (3 clause)
six>=1.9.0

View File

@ -16,6 +16,7 @@ from os import path
from oslo_log import fixture as log_fixture from oslo_log import fixture as log_fixture
from oslo_log import log as logging from oslo_log import log as logging
from oslotest import base from oslotest import base
import six
import sys import sys
sys.path.append(path.abspath(path.join(path.dirname(__file__), '../tools'))) sys.path.append(path.abspath(path.join(path.dirname(__file__), '../tools')))
@ -44,7 +45,7 @@ class BuildTest(base.BaseTestCase):
"ironic-discoverd"] "ironic-discoverd"]
failures = 0 failures = 0
for image, result in bad_results.iteritems(): for image, result in six.iteritems(bad_results):
if image in excluded_images: if image in excluded_images:
if result is 'error': if result is 'error':
continue continue