aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Zhang <zhang.lei.fly@gmail.com>2016-01-19 11:51:02 +0800
committerJeffrey Zhang <zhang.lei.fly@gmail.com>2016-01-20 20:46:12 +0800
commitf7f21949675e6a116799300abe8aba7a2d6fc90e (patch)
tree3c4a95a0d0c6fe83f9805931c302dd4190a2aa15
parent14dfbc13a25b43850be15933ca79a7d701b91bac (diff)
downloadkolla-f7f21949675e6a116799300abe8aba7a2d6fc90e.tar.gz
kolla-f7f21949675e6a116799300abe8aba7a2d6fc90e.zip
Import modules rather than objects
Base on the OpenStack Style Guidelines[0]: Do not import objects, only modules [0] http://docs.openstack.org/developer/hacking/index.html#imports TrivialFix Change-Id: Id1bc5e4b24fd561f1a9f6167af341b00a343a718
-rwxr-xr-xkolla/cmd/build.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py
index aff472d83..5a7913534 100755
--- a/kolla/cmd/build.py
+++ b/kolla/cmd/build.py
@@ -27,16 +27,15 @@ import signal
import sys
import tarfile
import tempfile
-from threading import Thread
+import threading
import time
import docker
import git
import jinja2
from oslo_config import cfg
-from requests.exceptions import ConnectionError
+from requests import exceptions as requests_exc
import six
-from six.moves import range
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../..'))
@@ -74,7 +73,7 @@ def docker_client():
return docker.Client(version='auto', **docker_kwargs)
-class PushThread(Thread):
+class PushThread(threading.Thread):
def __init__(self, conf, queue):
super(PushThread, self).__init__()
@@ -89,7 +88,7 @@ class PushThread(Thread):
image = self.queue.get()
LOG.debug('%s:Try to push the image', image['name'])
self.push_image(image)
- except ConnectionError:
+ except requests_exc.ConnectionError:
LOG.exception('%s:Make sure Docker is running and that you'
' have the correct privileges to run Docker'
' (root)', image['name'])
@@ -115,7 +114,7 @@ class PushThread(Thread):
LOG.error(stream['errorDetail']['message'])
-class WorkerThread(Thread):
+class WorkerThread(threading.Thread):
def __init__(self, queue, push_queue, conf):
self.conf = conf
@@ -142,12 +141,12 @@ class WorkerThread(Thread):
while True:
try:
image = self.queue.get()
- for _ in range(self.conf.retries + 1):
+ for _ in six.moves.range(self.conf.retries + 1):
self.builder(image)
if image['status'] in ['built', 'unmatched',
'parent_error']:
break
- except ConnectionError:
+ except requests_exc.ConnectionError:
LOG.exception('Make sure Docker is running and that you'
' have the correct privileges to run Docker'
' (root)')
@@ -639,12 +638,12 @@ def main():
conf.save_dependency)
return
- for x in range(conf.threads):
+ for x in six.moves.range(conf.threads):
worker = WorkerThread(queue, push_queue, conf)
worker.setDaemon(True)
worker.start()
- for x in range(conf.push_threads):
+ for x in six.moves.range(conf.push_threads):
push_thread = PushThread(conf, push_queue)
push_thread.start()