summaryrefslogtreecommitdiff
path: root/compose/parallel.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-08-09 16:46:47 -0700
committerJoffrey F <f.joffrey@gmail.com>2017-08-09 19:00:23 -0700
commit454b063fed20ba58338dd9754f3503fe17a1c1b8 (patch)
treece7ada78826f653ebd5cb06c9be1c56264c0ad25 /compose/parallel.py
parentb0b671dbf21cbbe749f209ac4217d3e35a92fdaa (diff)
Keep no-ansi parameter in the CLI scope
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'compose/parallel.py')
-rw-r--r--compose/parallel.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/compose/parallel.py b/compose/parallel.py
index 89d074e3..1cf1fb09 100644
--- a/compose/parallel.py
+++ b/compose/parallel.py
@@ -26,7 +26,7 @@ log = logging.getLogger(__name__)
STOP = object()
-def parallel_execute(objects, func, get_name, msg, get_deps=None, limit=None, noansi=False):
+def parallel_execute(objects, func, get_name, msg, get_deps=None, limit=None):
"""Runs func on objects in parallel while ensuring that func is
ran on object only after it is ran on all its dependencies.
@@ -36,7 +36,7 @@ def parallel_execute(objects, func, get_name, msg, get_deps=None, limit=None, no
objects = list(objects)
stream = get_output_stream(sys.stderr)
- writer = ParallelStreamWriter(stream, msg, noansi)
+ writer = ParallelStreamWriter(stream, msg)
for obj in objects:
writer.add_object(get_name(obj))
writer.write_initial()
@@ -221,12 +221,17 @@ class ParallelStreamWriter(object):
to jump to the correct line, and write over the line.
"""
- def __init__(self, stream, msg, noansi):
+ noansi = False
+
+ @classmethod
+ def set_noansi(cls, value=True):
+ cls.noansi = value
+
+ def __init__(self, stream, msg):
self.stream = stream
self.msg = msg
self.lines = []
self.width = 0
- self.noansi = noansi
def add_object(self, obj_index):
self.lines.append(obj_index)
@@ -267,27 +272,27 @@ class ParallelStreamWriter(object):
self._write_ansi(obj_index, status)
-def parallel_operation(containers, operation, options, message, noansi=False):
+def parallel_operation(containers, operation, options, message):
parallel_execute(
containers,
operator.methodcaller(operation, **options),
operator.attrgetter('name'),
message,
- noansi=noansi)
+ )
-def parallel_remove(containers, options, noansi=False):
+def parallel_remove(containers, options):
stopped_containers = [c for c in containers if not c.is_running]
- parallel_operation(stopped_containers, 'remove', options, 'Removing', noansi=noansi)
+ parallel_operation(stopped_containers, 'remove', options, 'Removing')
-def parallel_pause(containers, options, noansi=False):
- parallel_operation(containers, 'pause', options, 'Pausing', noansi=noansi)
+def parallel_pause(containers, options):
+ parallel_operation(containers, 'pause', options, 'Pausing')
-def parallel_unpause(containers, options, noansi=False):
- parallel_operation(containers, 'unpause', options, 'Unpausing', noansi=noansi)
+def parallel_unpause(containers, options):
+ parallel_operation(containers, 'unpause', options, 'Unpausing')
-def parallel_kill(containers, options, noansi=False):
- parallel_operation(containers, 'kill', options, 'Killing', noansi=noansi)
+def parallel_kill(containers, options):
+ parallel_operation(containers, 'kill', options, 'Killing')