Merge "Import modules rather than objects"
This commit is contained in:
commit
d3756de84c
@ -27,16 +27,15 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
from threading import Thread
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import docker
|
import docker
|
||||||
import git
|
import git
|
||||||
import jinja2
|
import jinja2
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from requests.exceptions import ConnectionError
|
from requests import exceptions as requests_exc
|
||||||
import six
|
import six
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
PROJECT_ROOT = os.path.abspath(os.path.join(
|
PROJECT_ROOT = os.path.abspath(os.path.join(
|
||||||
os.path.dirname(os.path.realpath(__file__)), '../..'))
|
os.path.dirname(os.path.realpath(__file__)), '../..'))
|
||||||
@ -74,7 +73,7 @@ def docker_client():
|
|||||||
return docker.Client(version='auto', **docker_kwargs)
|
return docker.Client(version='auto', **docker_kwargs)
|
||||||
|
|
||||||
|
|
||||||
class PushThread(Thread):
|
class PushThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, conf, queue):
|
def __init__(self, conf, queue):
|
||||||
super(PushThread, self).__init__()
|
super(PushThread, self).__init__()
|
||||||
@ -89,7 +88,7 @@ class PushThread(Thread):
|
|||||||
image = self.queue.get()
|
image = self.queue.get()
|
||||||
LOG.debug('%s:Try to push the image', image['name'])
|
LOG.debug('%s:Try to push the image', image['name'])
|
||||||
self.push_image(image)
|
self.push_image(image)
|
||||||
except ConnectionError:
|
except requests_exc.ConnectionError:
|
||||||
LOG.exception('%s:Make sure Docker is running and that you'
|
LOG.exception('%s:Make sure Docker is running and that you'
|
||||||
' have the correct privileges to run Docker'
|
' have the correct privileges to run Docker'
|
||||||
' (root)', image['name'])
|
' (root)', image['name'])
|
||||||
@ -115,7 +114,7 @@ class PushThread(Thread):
|
|||||||
LOG.error(stream['errorDetail']['message'])
|
LOG.error(stream['errorDetail']['message'])
|
||||||
|
|
||||||
|
|
||||||
class WorkerThread(Thread):
|
class WorkerThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, queue, push_queue, conf):
|
def __init__(self, queue, push_queue, conf):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
@ -142,12 +141,12 @@ class WorkerThread(Thread):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
image = self.queue.get()
|
image = self.queue.get()
|
||||||
for _ in range(self.conf.retries + 1):
|
for _ in six.moves.range(self.conf.retries + 1):
|
||||||
self.builder(image)
|
self.builder(image)
|
||||||
if image['status'] in ['built', 'unmatched',
|
if image['status'] in ['built', 'unmatched',
|
||||||
'parent_error']:
|
'parent_error']:
|
||||||
break
|
break
|
||||||
except ConnectionError:
|
except requests_exc.ConnectionError:
|
||||||
LOG.exception('Make sure Docker is running and that you'
|
LOG.exception('Make sure Docker is running and that you'
|
||||||
' have the correct privileges to run Docker'
|
' have the correct privileges to run Docker'
|
||||||
' (root)')
|
' (root)')
|
||||||
@ -639,12 +638,12 @@ def main():
|
|||||||
conf.save_dependency)
|
conf.save_dependency)
|
||||||
return
|
return
|
||||||
|
|
||||||
for x in range(conf.threads):
|
for x in six.moves.range(conf.threads):
|
||||||
worker = WorkerThread(queue, push_queue, conf)
|
worker = WorkerThread(queue, push_queue, conf)
|
||||||
worker.setDaemon(True)
|
worker.setDaemon(True)
|
||||||
worker.start()
|
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 = PushThread(conf, push_queue)
|
||||||
push_thread.start()
|
push_thread.start()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user