Selaa lähdekoodia

Reduce the args of some functions by including presenters as part of the thread_args.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 9 vuotta sitten
vanhempi
sitoutus
bf96edfe11
3 muutettua tiedostoa jossa 9 lisäystä ja 9 poistoa
  1. 3 0
      compose/cli/log_printer.py
  2. 4 7
      compose/cli/main.py
  3. 2 2
      tests/acceptance/cli_test.py

+ 3 - 0
compose/cli/log_printer.py

@@ -88,7 +88,10 @@ class LogPrinter(object):
 
             if not line:
                 if not thread_map:
+                    # There are no running containers left to tail, so exit
                     return
+                # We got an empty line because of a timeout, but there are still
+                # active containers to tail, so continue
                 continue
 
             self.output.write(line)

+ 4 - 7
compose/cli/main.py

@@ -389,7 +389,7 @@ class TopLevelCommand(object):
         }
         print("Attaching to", list_containers(containers))
         log_printer_from_project(
-            project,
+            self.project,
             containers,
             options['--no-color'],
             log_args).run()
@@ -708,10 +708,7 @@ class TopLevelCommand(object):
             raise UserError("--abort-on-container-exit and -d cannot be combined.")
 
         with up_shutdown_context(self.project, service_names, timeout, detached):
-            # start the event stream first so we don't lose any events
-            event_stream = project.events(service_names=service_names)
-
-            to_attach = project.up(
+            to_attach = self.project.up(
                 service_names=service_names,
                 start_deps=start_deps,
                 strategy=convergence_strategy_from_opts(options),
@@ -723,12 +720,12 @@ class TopLevelCommand(object):
                 return
 
             log_printer = log_printer_from_project(
-                project,
+                self.project,
                 filter_containers_to_service_names(to_attach, service_names),
                 options['--no-color'],
                 {'follow': True},
                 cascade_stop,
-                event_stream=event_stream)
+                event_stream=self.project.events(service_names=service_names))
             print("Attaching to", list_containers(log_printer.containers))
             log_printer.run()
 

+ 2 - 2
tests/acceptance/cli_test.py

@@ -396,8 +396,8 @@ class CLITestCase(DockerClientTestCase):
         self.base_dir = 'tests/fixtures/echo-services'
         result = self.dispatch(['up', '--no-color'])
 
-        assert 'simple_1  | simple' in result.stdout
-        assert 'another_1 | another' in result.stdout
+        assert 'simple_1   | simple' in result.stdout
+        assert 'another_1  | another' in result.stdout
         assert 'simple_1 exited with code 0' in result.stdout
         assert 'another_1 exited with code 0' in result.stdout