Exemplo n.º 1
0
 def _display_logs(self, attached, log_queue, term):
     current_container = None, None
     while attached:
         container, line = log_queue.get(timeout=60 * 60)
         if line is END_OF_STREAM:
             attached.remove(container)
             term.print_warning('{}: detached'.format(container))
         else:
             if container != current_container:
                 current_container = container
                 term.print_step(container)
             term.print_line(line.strip())
     term.print_warning('All containers detached')
Exemplo n.º 2
0
 def _update_env_from_local_env(env):
     '''Finds any environment variables with the special value '-' and looks
     them up from the host's environment, rather than trying to use a
     hard-coded value.
     '''
     new_env = {}
     for k, v in env.items():
         if v == '-':
             if k not in os.environ:
                 term.print_warning(
                     "Your localhost is missing dynamic environment "
                     "variable {!r}".format(k))
                 new_env[k] = ''
             else:
                 new_env[k] = os.environ[k]
         else:
             new_env[k] = v
     return new_env
Exemplo n.º 3
0
 def status(self):
     if self.created:
         status = self._docker_container_info['Status']
         status_string = '{!r} ({}): {}'.format(
             self.name, self.id, status)
         if status.startswith('Up'):
             term.print_step(status_string)
         else:
             term.print_warning(status_string)
         for port in self._docker_container_info['Ports']:
             if 'IP' in port:
                 term.print_line('{} {} [{}=>{}]'.format(
                     port['Type'],
                     port['IP'],
                     port['PrivatePort'],
                     port['PublicPort']))
             else:
                 term.print_line('{} [{}]'.format(
                     port['Type'],
                     port['PrivatePort']))
     else:
         term.print_step("container {!r} isn't created".format(self.name))
Exemplo n.º 4
0
 def remove(self, name):
     try:
         return self.clusters[name].remove()
     except ContainerNotCreatedError:
         term.print_warning('Containers were not present to be removed')