Change the device to execute on for the scope of the block.
519368
def use_device(cls, device):
        """"""
        if device == cls.ops.device:
            yield
        else:
            curr_Ops, curr_ops = (cls.Ops, cls.ops)
            cls.Ops = get_ops(device)
            cls.ops = cls.Ops()
            yield
            cls.Ops = curr_Ops
            cls.ops = curr_ops
860451
def call():
    """"""
    args = get_arguments()

    # Set up logging
    if args.debug:
        log_level = logging.DEBUG
    elif args.quiet:
        log_level = logging.WARN
    else:
        log_level = logging.INFO

    setup_logging(log_level)

    abode = None

    if not args.cache:
        if not args.username or not args.password:
            raise Exception("Please supply a cache or username and password.")

    try:
        # Create abodepy instance.
        if args.cache and args.username and args.password:
            abode = abodepy.Abode(username=args.username,
                                  password=args.password,
                                  get_devices=True,
                                  cache_path=args.cache)
        elif args.cache and not (not args.username or not args.password):
            abode = abodepy.Abode(get_devices=True,
                                  cache_path=args.cache)
        else:
            abode = abodepy.Abode(username=args.username,
                                  password=args.password,
                                  get_devices=True)

        # Output current mode.
        if args.mode:
            _LOGGER.info("Current alarm mode: %s", abode.get_alarm().mode)

        # Change system mode.
        if args.arm:
            if abode.get_alarm().set_mode(args.arm):
                _LOGGER.info("Alarm mode changed to: %s", args.arm)
            else:
                _LOGGER.warning("Failed to change alarm mode to: %s", args.arm)

        # Set setting
        for setting in args.set or []:
            keyval = setting.split("=")
            if abode.set_setting(keyval[0], keyval[1]):
                _LOGGER.info("Setting %s changed to %s", keyval[0], keyval[1])

        # Switch on
        for device_id in args.on or []:
            device = abode.get_device(device_id)

            if device:
                if device.switch_on():
                    _LOGGER.info("Switched on device with id: %s", device_id)
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Switch off
        for device_id in args.off or []:
            device = abode.get_device(device_id)

            if device:
                if device.switch_off():
                    _LOGGER.info("Switched off device with id: %s", device_id)
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Lock
        for device_id in args.lock or []:
            device = abode.get_device(device_id)

            if device:
                if device.lock():
                    _LOGGER.info("Locked device with id: %s", device_id)
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Unlock
        for device_id in args.unlock or []:
            device = abode.get_device(device_id)

            if device:
                if device.unlock():
                    _LOGGER.info("Unlocked device with id: %s", device_id)
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Output Json
        for device_id in args.json or []:
            device = abode.get_device(device_id)

            if device:
                # pylint: disable=protected-access
                _LOGGER.info(device_id + " JSON:\n" +
                             json.dumps(device._json_state, sort_keys=True,
                                        indent=4, separators=(',', ': ')))
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Print
        def _device_print(dev, append=''):
            _LOGGER.info("%s%s",
                         dev.desc, append)

        # Print out all automations
        if args.automations:
            for automation in abode.get_automations():
                _device_print(automation)

        # Enable automation
        for automation_id in args.activate or []:
            automation = abode.get_automation(automation_id)

            if automation:
                if automation.set_active(True):
                    _LOGGER.info(
                        "Activated automation with id: %s", automation_id)
            else:
                _LOGGER.warning(
                    "Could not find automation with id: %s", automation_id)

        # Disable automation
        for automation_id in args.deactivate or []:
            automation = abode.get_automation(automation_id)

            if automation:
                if automation.set_active(False):
                    _LOGGER.info(
                        "Deactivated automation with id: %s", automation_id)
            else:
                _LOGGER.warning(
                    "Could not find automation with id: %s", automation_id)

        # Trigger automation
        for automation_id in args.trigger or []:
            automation = abode.get_automation(automation_id)

            if automation:
                if automation.trigger():
                    _LOGGER.info(
                        "Triggered automation with id: %s", automation_id)
            else:
                _LOGGER.warning(
                    "Could not find automation with id: %s", automation_id)

        # Trigger image capture
        for device_id in args.capture or []:
            device = abode.get_device(device_id)

            if device:
                if device.capture():
                    _LOGGER.info(
                        "Image requested from device with id: %s", device_id)
                else:
                    _LOGGER.warning(
                        "Failed to request image from device with id: %s",
                        device_id)
            else:
                _LOGGER.warning("Could not find device with id: %s", device_id)

        # Save camera image
        for keyval in args.image or []:
            devloc = keyval.split("=")
            device = abode.get_device(devloc[0])

            if device:
                try:
                    if (device.refresh_image() and
                            device.image_to_file(devloc[1])):
                        _LOGGER.info(
                            "Saved image to %s for device id: %s", devloc[1],
                            devloc[0])
                except AbodeException as exc:
                    _LOGGER.warning("Unable to save image: %s", exc)
            else:
                _LOGGER.warning(
                    "Could not find device with id: %s", devloc[0])

        # Print out all devices.
        if args.devices:
            for device in abode.get_devices():
                _device_print(device)

        def _device_callback(dev):
            _device_print(dev, ", At: " + time.strftime("%Y-%m-%d %H:%M:%S"))

        def _timeline_callback(tl_json):
            event_code = int(tl_json['event_code'])
            if 5100 <= event_code <= 5199:
                # Ignore device changes
                return

            _LOGGER.info("%s - %s at %s %s",
                         tl_json['event_name'], tl_json['event_type'],
                         tl_json['date'], tl_json['time'])

        # Print out specific devices by device id.
        if args.device:
            for device_id in args.device:
                device = abode.get_device(device_id)

                if device:
                    _device_print(device)

                    # Register the specific devices if we decide to listen.
                    abode.events.add_device_callback(device_id,
                                                     _device_callback)
                else:
                    _LOGGER.warning(
                        "Could not find device with id: %s", device_id)

        # Start device change listener.
        if args.listen:
            # If no devices were specified then we listen to all devices.
            if args.device is None:
                _LOGGER.info("Adding all devices to listener...")

                for device in abode.get_devices():
                    abode.events.add_device_callback(device.device_id,
                                                     _device_callback)

            abode.events.add_timeline_callback(TIMELINE.ALL,
                                               _timeline_callback)

            _LOGGER.info("Listening for device and timeline updates...")
            abode.events.start()
            try:
                while True:
                    time.sleep(1)
            except KeyboardInterrupt:
                abode.events.stop()
                _LOGGER.info("Device update listening stopped.")
    except abodepy.AbodeException as exc:
        _LOGGER.error(exc)
    finally:
        if abode:
            abode.logout()
451310
public DelegationRequest<T> setScope(String scope) {
        request.addParameter(ParameterBuilder.SCOPE_KEY, scope);
        return this;
    }
1157394
def init_device(self):
        """"""
        Device.init_device(self)

        # Add anything here that has to be done before the device is set to
        # its ON state.

        self._set_master_state('on')
        self._devProxy = DeviceProxy(self.get_name())
354419
function BlockDevice( options ) {

  if( !(this instanceof BlockDevice) )
    return new BlockDevice( options )

  options = options != null ?
    options : {}

  this.fs = options.fs || require( 'fs' )
  this.fd = options.fd
  this.path = options.path
  this.mode = options.mode || 'r'

  this.blockSize = options.blockSize || -1
  this.size = options.size || -1

  // Heads per Track (for CHS addressing)
  this.headsPerTrack = options.headsPerTrack || -1
  // Sectors per Track (for CHS addressing)
  this.sectorsPerTrack = options.sectorsPerTrack || -1

  Object.defineProperty( this, 'fs', {
    enumerable: false
  })

}
472395
def update(self):
        """"""
        node = self._fritz.get_device_element(self.ain)
        self._update_from_node(node)
178888
def add_override(self, addr, key, value):
        """"""
        address = Address(str(addr)).id
        _LOGGER.debug('New override for %s %s is %s', address, key, value)
        device_override = self._overrides.get(address, {})
        device_override[key] = value
        self._overrides[address] = device_override
105616
def _lock(self):
        """"""
        if not self.locked:
            try:
                self.device.cu.lock()
                self.locked = True
            except JnprLockError as jle:
                raise LockError(py23_compat.text_type(jle))
46821
def toggle(self):
        
        for device in self:
            if isinstance(device, (OutputDevice, CompositeOutputDevice)):
                device.toggle()
240733
def set_device(request, device=""):
    
    response = redirect(add_cache_bypass(next_url(request) or "/"))
    set_cookie(response, "yacms-device", device, 60 * 60 * 24 * 365)
    return response
525567
def _configure_device(commands, **kwargs):
    '''
    
    '''
    if salt.utils.platform.is_proxy():
        return __proxy__['nxos.proxy_config'](commands, **kwargs)
    else:
        return _nxapi_config(commands, **kwargs)
199405
void onStart(Device device) {
	  KernelDeviceProfile currentDeviceProfile = deviceProfiles.get(device);
      if (currentDeviceProfile == null) {    	 
         currentDeviceProfile = new KernelDeviceProfile(this, kernelClass, device);
         KernelDeviceProfile existingProfile = deviceProfiles.putIfAbsent(device, currentDeviceProfile);
         if (existingProfile != null) {
        	 currentDeviceProfile = existingProfile;
         }
      }
      
      currentDeviceProfile.onEvent(ProfilingEvent.START);
      currentDevice.set(device);
   }
570124
def on(device):
    '''
    
    '''
    cmd = 'quotaon {0}'.format(device)
    __salt__['cmd.run'](cmd, python_shell=False)
    return True
559931
def init_device(self):
        """"""
        start_time = time.time()
        Device.init_device(self)
        self._pb_id = ''
        LOG.debug('init PB device %s, time taken %.6f s (total: %.2f s)',
                  self.get_name(), (time.time() - start_time),
                  (time.time() - self._start_time))
        self.set_state(DevState.STANDBY)
628449
def set_value(self, value):
        """"""
        self._value = value

        for proxy in self.get_proxies():
            proxy.handler_block(self._changed_handlers[proxy])
            proxy.set_value(self._value)
            proxy.handler_unblock(self._changed_handlers[proxy])
            pass

        self.emit('changed')
        return
1284543
def activate_shell_scope(self):
        """"""
        self.variables = {}
        self.prompt = 'cm> '
        self.active_scope = ""
        self.scopes = []
        self.scopeless = ['load', 'info', 'var', 'use', 'quit', 'q', 'help']
883721
def async_state_change_callback(self, addr, state, value):
        """"""
        _LOGGING.info('Device %s state %s value is changed to %s',
                      addr, state, value)