Attach to console of running container.
421166
def console_getfd(self, ttynum=-1):
        

        if not self.running:
            return False

        return _lxc.Container.console_getfd(self, ttynum)
471686
def attach_to_container(self, container_id):
        
        sock = self._docker.containers.get(container_id).attach_socket(params={
            'stdin': 1,
            'stdout': 1,
            'stderr': 0,
            'stream': 1,
        })
        # fix a problem with docker-py; we must keep a reference of sock at every time
        return FixDockerSocket(sock)
795680
def attach(self, canvas):
        """"""
        self.canvas = canvas

        @canvas.connect
        def on_visual_added(e):
            self.update_program(e.visual.program)
542724
def internal_run_container(name, callback_method, foreground=False):
        
        if not foreground:
            logger.info("Stating machine (boot nspawn container) {}".format(name))
            # wait until machine is booted when running at background, unable to execute commands without logind
            # in running container
            nspawn_process = NspawnContainer._internal_reschedule(callback_method)
            NspawnContainer._wait_for_machine_booted(name)
            logger.info("machine: %s starting finished" % name)
            return nspawn_process
        else:
            logger.info("Stating machine (return process) {}".format(name))
            return callback_method[0](callback_method[1], *callback_method[2], **callback_method[3])
125310
def post_register_hook(self, verbosity=1):
        """"""
        if not getattr(settings, 'FLOW_DOCKER_DONT_PULL', False):
            call_command('list_docker_images', pull=True, verbosity=verbosity)
779953
public function run(): void
    {
        foreach ($this->hooks as $hook) {
            $hook->setContainer($this->container);
            $hook->register();
        }
    }
857895
def set_input_container(_container, cfg):
    """"""
    if not _container:
        return False
    if _container.exists():
        cfg["container"]["input"] = str(_container)
        return True
    return False
126220
def register_plugin(self):
        """"""
        self.main.restore_scrollbar_position.connect(
            self.restore_scrollbar_position)
        self.main.console.edit_goto.connect(self.load)
        self.exec_in_extconsole.connect(self.main.execute_in_external_console)
        self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
        self.open_dir.connect(self.main.workingdirectory.chdir)
        self.set_help(self.main.help)
        if self.main.outlineexplorer is not None:
            self.set_outlineexplorer(self.main.outlineexplorer)
        editorstack = self.get_current_editorstack()
        if not editorstack.data:
            self.__load_temp_file()
        self.main.add_dockwidget(self)
        self.main.add_to_fileswitcher(self, editorstack.tabs, editorstack.data,
                                      ima.icon('TextFileIcon'))
218725
public static void attachAndEnhance(JQMContainer container) {
        if (container == null) return;
        RootPanel p = getRootPanel();
        if (p == null) return;
        p.add(container);
        enhance(container);
        container.setEnhanced(true);
    }
766213
public static void onStartup(String container, Object containerContext) {
        try {
            startedUp = false;
            logger = LoggerUtil.getStandardLogger();
            containerName = container;

            // use reflection to avoid build-time dependencies
            String pluginPackage = MdwDataSource.class.getPackage().getName() + "." + containerName.toLowerCase();
            String namingProviderClass = pluginPackage + "." + containerName + "Naming";
            namingProvider = Class.forName(namingProviderClass).asSubclass(NamingProvider.class).newInstance();
            logger.info("Naming Provider: " + namingProvider.getClass().getName());

            String ds = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_DATASOURCE_PROVIDER);
            if (ds == null)
                ds = PropertyManager.getProperty("mdw.container.datasource_provider"); // compatibility
            if (StringHelper.isEmpty(ds) || ds.equals(DataSourceProvider.TOMCAT)) {
                dataSourceProvider = new TomcatDataSource();
            } else if (DataSourceProvider.MDW.equals(ds)){
                dataSourceProvider = new MdwDataSource();
            } else {
                String dsProviderClass = pluginPackage + "." + ds + "DataSource";
                dataSourceProvider = Class.forName(dsProviderClass).asSubclass(DataSourceProvider.class).newInstance();
            }
            logger.info("Data Source Provider: " + dataSourceProvider.getClass().getName());

            String jms = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_JMS_PROVIDER);
            if (jms == null)
                jms = PropertyManager.getProperty("mdw.container.jms_provider"); // compatibility
            if (StringHelper.isEmpty(jms))
                jms = JmsProvider.ACTIVEMQ;

            if (JmsProvider.ACTIVEMQ.equals(jms)) {
                if (jmsProvider == null) {
                    // use below to avoid build time dependency
                    jmsProvider = Class.forName("com.centurylink.mdw.container.plugin.activemq.ActiveMqJms").asSubclass(JmsProvider.class).newInstance();
                }
            }
            else {
                String jmsProviderClass = pluginPackage + "." + jms + "Jms";
                jmsProvider = Class.forName(jmsProviderClass).asSubclass(JmsProvider.class).newInstance();
            }

            logger.info("JMS Provider: " + (jmsProvider==null?"none":jmsProvider.getClass().getName()));

            String tp = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_THREADPOOL_PROVIDER);
            if (tp == null)
                tp = PropertyManager.getProperty("mdw.container.threadpool_provider"); // compatibility
            if (StringHelper.isEmpty(tp) || ThreadPoolProvider.MDW.equals(tp)) {
                threadPoolProvider = new CommonThreadPool();
                MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                ObjectName mbeanName = new ObjectName("com.centurylink.mdw.container.plugin:type=CommonThreadPool,name=MDW Thread Pool Info");
                if (!mbs.isRegistered(mbeanName))
                    mbs.registerMBean(threadPoolProvider, mbeanName);
            }
            else {
                String tpProviderClass = pluginPackage + "." + tp + "ThreadPool";
                threadPoolProvider = Class.forName(tpProviderClass).asSubclass(ThreadPoolProvider.class).newInstance();
            }
            logger.info("Thread Pool Provider: " + threadPoolProvider.getClass().getName());

            startedUp = true;
            startupTime = new Date();
        }
        catch (Exception ex) {
            throw new StartupException("Failed to initialize ApplicationContext", ex);
        }
    }
447660
public void attach(JComponent owner) {
        detach();
        toolTipDialog = new TransparentToolTipDialog(owner, new AnchorLink(Anchor.CENTER_RIGHT, Anchor.CENTER_LEFT));
    }
1238834
def start(self, attach=False):
        
        if self.state()['running']:
            logger.info('is already running.', extra={'formatter': 'container', 'container': self.name})
            return True
        else:
            try:
                logger.info(
                    'is being started.', extra={'formatter': 'container', 'container': self.name}
                )

                # returns None on success
                self.client.start(self.id)
                if self._transcribe:
                    self.start_transcribing()

            except APIError as e:
                #
                # This is some bs... I assume that its needed because of dockers changes in 1.18 api.
                # I will resolve this next week when we stop passing properties to start.

                if e.response.status_code == 500:
                    self.client.start(self.id)
                else:
                    raise RuntimeError("Docker Error: {0}".format(e.explanation))

            if attach:
                self.attach()
                exit_code = self.wait()

            else:
                exit_code = self._wait_for_exit_code()

            return True if exit_code == 0 else False
1129388
def set_attached_console_visible(state):
    """"""
    flag = {True: SW_SHOW, False: SW_HIDE}
    return bool(ShowWindow(console_window_handle, flag[state]))
877733
def _start_services(self, console_env):
        """"""
        self._ad.load_snippet(name='snippet', package=self._package)
        console_env['snippet'] = self._ad.snippet
        console_env['s'] = self._ad.snippet
666041
def run_container(self, image_id, service_name, **kwargs):
        """"""
        run_kwargs = self.run_kwargs_for_service(service_name)
        run_kwargs.update(kwargs, relax=True)
        logger.debug('Running container in docker', image=image_id, params=run_kwargs)

        container_obj = self.client.containers.run(
            image=image_id,
            detach=True,
            **run_kwargs
        )

        log_iter = container_obj.logs(stdout=True, stderr=True, stream=True)
        mux = logmux.LogMultiplexer()
        mux.add_iterator(log_iter, plainLogger)
        return container_obj.id
569921
def setup_container(builddir, _container):
    """"""
    build_dir = local.path(builddir)
    in_dir = build_dir / "container-in"
    container_path = local.path(_container)
    with local.cwd(builddir):
        container_bin = container_path.basename
        container_in = in_dir / container_bin
        download.Copy(_container, container_in)
        uchrt = uchroot.no_args()

        with local.cwd("container-in"):
            uchrt = uchrt["-E", "-A", "-u", "0", "-g", "0", "-C", "-r", "/",
                          "-w",
                          os.path.abspath("."), "--"]

        # Check, if we need erlent support for this archive.
        has_erlent = bash[
            "-c", "tar --list -f './{0}' | grep --silent '.erlent'".format(
                container_in)]
        has_erlent = (has_erlent & TF)

        # Unpack input container to: container-in
        if not has_erlent:
            cmd = local["/bin/tar"]["xf"]
            cmd = uchrt[cmd[container_bin]]
        else:
            cmd = tar["xf"]
            cmd = cmd[container_in]

        with local.cwd("container-in"):
            cmd("--exclude=dev/*")
        rm(container_in)
    return in_dir
1156428
private void onContainerStatus(final ContainerStatus value) {

    final String containerId = value.getContainerId().toString();
    final boolean hasContainer = this.containers.hasContainer(containerId);

    if (hasContainer) {
      LOG.log(Level.FINE, "Received container status: {0}", containerId);

      final ResourceStatusEventImpl.Builder status =
          ResourceStatusEventImpl.newBuilder().setIdentifier(containerId);

      switch (value.getState()) {
      case COMPLETE:
        LOG.log(Level.FINE, "Container completed: status {0}", value.getExitStatus());
        switch (value.getExitStatus()) {
        case 0:
          status.setState(State.DONE);
          break;
        case 143:
          status.setState(State.KILLED);
          break;
        default:
          status.setState(State.FAILED);
        }
        status.setExitCode(value.getExitStatus());
        break;
      default:
        LOG.info("Container running");
        status.setState(State.RUNNING);
      }

      if (value.getDiagnostics() != null) {
        LOG.log(Level.FINE, "Container diagnostics: {0}", value.getDiagnostics());
        status.setDiagnostics(value.getDiagnostics());
      }

      // ResourceStatusHandler should close and release the Evaluator for us if the state is a terminal state.
      this.reefEventHandlers.onResourceStatus(status.build());
    }
  }