Run `code` in a container, returning its ID
518462
def run_code_in_container(cli, image, code, mount, entrypoint):
    
    kwargs = {
        'image': image,
    }

    if entrypoint:
        kwargs['entrypoint'] = '/bin/bash'
        kwargs['command'] = '-c {}'.format(quote(code))
    else:
        kwargs['command'] = '/bin/bash -c {}'.format(quote(code))

    if mount:
        binds = []
        volumes = []

        for m in mount:
            part = m.split(':')

            if len(part) == 3:
                pass
            elif len(part) == 2:
                part.append('rw')
            else:
                raise

            src, target, mode = part
            src = os.path.abspath(os.path.expanduser(src))

            binds.append('{}:{}:{}'.format(src, target, mode))
            volumes.append(target)

        kwargs['host_config'] = cli.create_host_config(binds=binds)
        kwargs['volumes'] = volumes

    container = cli.create_container(**kwargs)
    container_id = container['Id']

    cli.start(container=container_id)

    return container_id
335287
function(cid) {
    // Validate input.
    return Promise.try(function() {
      if (typeof cid !== 'string') {
        throw new VError('Invalid cid: ' + pp(cid));
      }
    })
    // Inspect.
    .then(function() {
      return inspect(cid);
    })
    .then(function(data) {
      return _.get(data, 'State.Running', false);
    })
    // If the container no longer exists, return false since it isn't running.
    // This will prevent a race condition from happening.
    // Wrap errors.
    .catch(function(err) {
      var expected = format('The container "\'%s\'" does not exist!', cid);
      if (_.endsWith(err.message, expected)) {
        return false;
      } else {
        // Wrap errors.
        throw new VError(err, 'Error querying isRunning: "%s".', pp(cid));
      }
    });
  }
1039872
def run(self, *args):
        """"""

        uuid, kwargs = self.__parse_arguments(*args)
        code = self.edit_profile(uuid, **kwargs)

        return code
945882
def run_container():
    """"""

    os.chdir(my_directory)

    cmd = [
        'docker', 'run',
        '-it', '--rm',
        '-v', '{}:/cauldron'.format(my_directory),
        '-p', '5010:5010',
        'cauldron_app',
        '/bin/bash'
    ]

    return os.system(' '.join(cmd))
215826
def _run_code(code, run_globals, init_globals=None,
              mod_name=None, mod_fname=None,
              mod_loader=None, pkg_name=None):
    """"""
    if init_globals is not None:
        run_globals.update(init_globals)
    run_globals.update(__name__ = mod_name,
                       __file__ = mod_fname,
                       __loader__ = mod_loader,
                       __package__ = pkg_name)
    exec code in run_globals
    return run_globals
1325559
def container_by_id(self, id):
        
        if not id:
            return None
        return next((container for container in self.containers(all=True)
                     if container['Id'] == id), None)
392916
def run_in_container(command, container_dir):
    
    container_p = local.path(container_dir)
    with local.cwd(container_p):
        uchrt = uchroot.with_mounts()
        uchrt = uchrt["-E", "-A", "-u", "0", "-g", "0", "-C", "-w", "/", "-r",
                      container_p]
        uchrt = uchrt["--"]

        cmd_path = container_p / command[0].lstrip('/')
        if not cmd_path.exists():
            LOG.error("The command does not exist inside the container! %s",
                      cmd_path)
            return

        cmd = uchrt[command]
        return cmd & FG
218843
def run_code(node: Code, parent_node: Node = None, node_globals: InheritedDict = None, **args): #pylint: disable=unused-argument
    ''''''
    if not node.xml_node.text:
        return
    code = node.xml_node.text
    try:
        globs = node_globals.to_dictionary()
        exec(dedent(code), globs) #pylint: disable=exec-used
        definitions = [(key, value) for key, value in globs.items() \
                       if key != '__builtins__' and not node_globals.has_key(key)]
        for key, value in definitions:
            parent_node.node_globals[key] = value
    except SyntaxError as err:
        error = _get_compilation_error(code, 'Invalid syntax', err, err.lineno)
        raise error from err
    except:
        info = exc_info()
        cause = info[1]
        line_number = extract_tb(info[2])[-1][1]
        error = _get_compilation_error(code, 'Code execution is failed', cause, line_number)
        raise error from cause
944855
def _get_code(data, position, obj_end, opts, element_name):
    """"""
    code, position = _get_string(data, position, obj_end, opts, element_name)
    return Code(code), position
1091450
def run(self, *args):
        
        params = self.parser.parse_args(args)

        from_uuid = params.from_uuid
        to_uuid = params.to_uuid

        code = self.merge(from_uuid, to_uuid)

        return code
427302
def strip_id_wrapper(code, stdclass)
      prefix = @registry.processors[stdclass].prefix
      code = code.sub(/^#{prefix}\((.+)\)$/, "\\1")
      [prefix, code]
    end
51022
def container_exit_code(container_id: str) -> Optional[int]:
    
    container = docker_client.containers.get(container_id)
    return container.wait()["StatusCode"]
1201717
def run_command(self, codeobj):
        """"""
        try:
            value, stdout = yield from self.attempt_exec(codeobj, self.namespace)
        except Exception:
            yield from self.send_exception()
            return
        else:
            yield from self.send_output(value, stdout)
208242
def run(path, code=None, params=None, **meta):
        
        import _ast

        builtins = params.get("builtins", "")

        if builtins:
            builtins = builtins.split(",")

        tree = compile(code, path, "exec", _ast.PyCF_ONLY_AST)
        w = checker.Checker(tree, path, builtins=builtins)
        w.messages = sorted(w.messages, key=lambda m: m.lineno)
        return [{
            'lnum': m.lineno,
            'text': m.message % m.message_args,
            'type': m.message[0]
        } for m in w.messages]
1018832
def run(self, *args):
        """"""

        params = self.parser.parse_args(args)

        code = self.show(params.uuid, params.term)

        return code
528617
def inspect(self, refresh=True):
        
        if refresh or not self._inspect_data:
            identifier = self._id or self.name
            if not identifier:
                raise ConuException("This container does not have a valid identifier.")
            self._inspect_data = self._inspect(identifier)
        return self._inspect_data
404707
def eval(self, code, mode='single'):
        """"""
        if isinstance(code, str):
            if isinstance(code, str):
                code = UTF8_COOKIE + code.encode('utf-8')
            code = compile(code, '<interactive>', mode)
        if mode != 'exec':
            return eval(code, self.globals, self.locals)
        exec(code, self.globals, self.locals)