Launch an instance of the given image.
19994
def _launch_instance(self):
        """"""
        metadata = {'key': 'ssh-keys', 'value': self.ssh_public_key}
        self.running_instance_id = ipa_utils.generate_instance_name(
            'gce-ipa-test'
        )
        self.logger.debug('ID of instance: %s' % self.running_instance_id)

        kwargs = {
            'location': self.region,
            'ex_metadata': metadata,
            'ex_service_accounts': [{
                'email': self.service_account_email,
                'scopes': ['storage-ro']
            }]
        }

        if self.subnet_id:
            kwargs['ex_subnetwork'] = self._get_subnet(self.subnet_id)
            kwargs['ex_network'] = kwargs['ex_subnetwork'].network

        try:
            instance = self.compute_driver.create_node(
                self.running_instance_id,
                self.instance_type or GCE_DEFAULT_TYPE,
                self.image_id,
                **kwargs
            )
        except ResourceNotFoundError as error:
            try:
                message = error.value['message']
            except TypeError:
                message = error

            raise GCECloudException(
                'An error occurred launching instance: {message}.'.format(
                    message=message
                )
            )

        self.compute_driver.wait_until_running(
            [instance],
            timeout=self.timeout
        )
452269
def launch_instance(instance_name,
                    command,
                    existing_ip=None,
                    cpu=1,
                    mem=4,
                    code_dir=None,
                    setup_command=None):
  """"""
  # Create instance
  ip = existing_ip or create_instance(instance_name, cpu=cpu, mem=mem)
  tf.logging.info("Waiting for SSH %s", instance_name)
  ready = wait_for_ssh(ip)
  if not ready:
    raise ValueError("Instance %s never ready for SSH" % instance_name)

  # Copy code
  if code_dir:
    shell_run_with_retry(COPY_CODE, retries=2,
                         local_dir=code_dir, instance_name=instance_name)

  # Run setup
  if setup_command:
    tf.logging.info("Running setup on %s", instance_name)
    remote_run(setup_command, instance_name)

  # Run command
  tf.logging.info("Running command on %s", instance_name)
  remote_run(command, instance_name, detach=True)
1356116
def _on_startup(self, *args):
        
        yield from Controller.instance().start()
        # Because with a large image collection
        # without md5sum already computed we start the
        # computing with server start
        asyncio.async(Qemu.instance().list_images())
1017824
def set_custom_image(user_context, app_id, image_path):
  """"""
  if image_path is None:
    return False

  if not os.path.exists(image_path):
    return False

  (root, ext) = os.path.splitext(image_path)
  if not is_valid_extension(ext):
    # TODO: Maybe log that this happened?
    return False
  # If we don't remove the old image then theres no guarantee that Steam will
  # show our new image when it launches.
  if has_custom_image(user_context, app_id):
    img = get_custom_image(user_context, app_id)
    assert(img is not None)
    os.remove(img)
  
  # Set the new image
  parent_dir = paths.custom_images_directory(user_context)
  new_path = os.path.join(parent_dir, app_id + ext)
  shutil.copyfile(image_path, new_path)
  return True
570645
def load_img(name):
    """"""

    fullname = name
    try:
        image = pygame.image.load(fullname)
        if image.get_alpha() is None:
            image = image.convert()
        else:
            image = image.convert_alpha()
    except pygame.error, message:
        print "Error: couldn't load image: ", fullname
        raise SystemExit, message
    return (image, image.get_rect())
378981
def run_container(self, conf, images, **kwargs):
        """"""
        with self._run_container(conf, images, **kwargs):
            pass
682692
public void setImage(T image) {
		this.image = image;

		// precompute offsets for faster computing later on
		for( int i = 0; i < definition.samplePoints.length ; i++ ) {
			Point2D_I32 a = definition.samplePoints[i];

			offsets[i] = image.stride*a.y + a.x;
		}

		for( int i = 0; i < definition.compare.length ; i++ ) {
			Point2D_I32 p = definition.compare[i];
			offsetsA[i] = offsets[p.x];
			offsetsB[i] = offsets[p.y];
		}
	}
661418
async def run(self, config, *, name=None):
        
        try:
            container = await self.create(config, name=name)
        except DockerError as err:
            # image not find, try pull it
            if err.status == 404 and "Image" in config:
                await self.docker.pull(config["Image"])
                container = await self.create(config, name=name)
            else:
                raise err

        try:
            await container.start()
        except DockerError as err:
            raise DockerContainerError(
                err.status, {"message": err.message}, container["id"]
            )

        return container
298810
def __callback (self, img):
        '''
        

        '''
        image = imageMsg2Image(img, self.bridge)

        self.lock.acquire()
        self.data = image
        self.lock.release()
55610
def start(self):
        

        status = yield from self.get_status()
        if status == "suspended":
            yield from self.resume()
        elif status == "inactive":

            if not os.path.isfile(self._image) or not os.path.exists(self._image):
                if os.path.islink(self._image):
                    raise DynamipsError('IOS image "{}" linked to "{}" is not accessible'.format(self._image, os.path.realpath(self._image)))
                else:
                    raise DynamipsError('IOS image "{}" is not accessible'.format(self._image))

            try:
                with open(self._image, "rb") as f:
                    # read the first 7 bytes of the file.
                    elf_header_start = f.read(7)
            except OSError as e:
                raise DynamipsError('Cannot read ELF header for IOS image "{}": {}'.format(self._image, e))

            # IOS images must start with the ELF magic number, be 32-bit, big endian and have an ELF version of 1
            if elf_header_start != b'\x7fELF\x01\x02\x01':
                raise DynamipsError('"{}" is not a valid IOS image'.format(self._image))

            # check if there is enough RAM to run
            if not self._ghost_flag:
                self.check_available_ram(self.ram)

            # config paths are relative to the working directory configured on Dynamips hypervisor
            startup_config_path = os.path.join("configs", "i{}_startup-config.cfg".format(self._dynamips_id))
            private_config_path = os.path.join("configs", "i{}_private-config.cfg".format(self._dynamips_id))

            if not os.path.exists(os.path.join(self._working_directory, private_config_path)) or \
               not os.path.getsize(os.path.join(self._working_directory, private_config_path)):
                # an empty private-config can prevent a router to boot.
                private_config_path = ''

            yield from self._hypervisor.send('vm set_config "{name}" "{startup}" "{private}"'.format(
                name=self._name,
                startup=startup_config_path,
                private=private_config_path))
            yield from self._hypervisor.send('vm start "{name}"'.format(name=self._name))
            self.status = "started"
            log.info('router "{name}" [{id}] has been started'.format(name=self._name, id=self._id))

            self._memory_watcher = FileWatcher(self._memory_files(), self._memory_changed, strategy='hash', delay=30)
            monitor_process(self._hypervisor.process, self._termination_callback)
292322
def image(self, img):
        """"""
        if img.mode != '1':
            raise ValueError('Image must be in mode 1.')
        imwidth, imheight = img.size
        if imwidth != self.width or imheight != self.height:
            raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
                .format(self.width, self.height))
        # Grab all the pixels from the image, faster than getpixel.
        pixels = img.load()
        # Clear buffer
        for i in range(len(self.buf)):
            self.buf[i] = 0
        # Iterate through the pixels
        for x in range(self.width):       # yes this double loop is slow,
            for y in range(self.height):  #  but these displays are small!
                if pixels[(x, y)]:
                    self.pixel(x, y, 1)
759092
public static BufferedImage cloneImage( BufferedImage image ) {
		BufferedImage newImage = new BufferedImage( image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB );
		Graphics2D g = newImage.createGraphics();
		g.drawRenderedImage( image, null );
		g.dispose();
		return newImage;
	}
1114220
def load(self, image=None):
    ''' 

    '''
    from spython.image import Image
    from spython.instance import Instance

    self.simage = Image(image)

    if image is not None:
        if image.startswith('instance://'):
            self.simage = Instance(image)
        bot.info(self.simage)
1332033
public void setImage(T image ) {
		match.setInputImage(image);
		this.imageWidth = image.width;
		this.imageHeight = image.height;
	}
429634
function Image(src) {
  if (!(this instanceof Image)) {
    return new Image(src)
  }

  if (typeof src !== 'string') {
    throw new Error('param `src` must be a string')
  }

  var ret = reg.exec(src)

  if (!ret) {
    throw new Error('invalid param `src`')
  }

  this.src = src
  this.host = ret[1] || defaultHost
  this.version = ret[2] ? ret[2].slice(0, -1) : ''
  this.hash = ret[3]
  this.ext = ret[4]
}
1270069
def create(self, width, height):
        
        return Image.new(self.mode, (width, height))
1352554
def load_from(self, image):
        
        if not isinstance(image, self.__class__):
            raise ConuException("Invalid source image type", type(image))
        image.save_to(self)