find drone by uid, update drone state and clear proxy routes
768129
function findSwitchAndClear(uid) {
    if (uid) {
      droneModel.getProcessed({uid: uid}, function(err, result) {
        if (!err && result && result.length == 1) {
          switchAndClear(result[0]);
        }
      });
    }
  }
252280
def _rt_state_update(route_table_id, dcidr, router_ip="(none)",
                     instance_id="(none)", eni_id="(none)",
                     old_router_ip="(none)", msg="(none)"):
    
    buf = "inst: %s, eni: %s, r_ip: %-15s, o_r_ip: %-15s, msg: %s" % \
          (instance_id, eni_id, router_ip, old_router_ip, msg)
    CURRENT_STATE.vpc_state.setdefault('route_tables', {}). \
                            setdefault(route_table_id, {})[dcidr] = buf
711766
def delete_local(route_dist, prefix, route_family=VRF_RF_IPV4):
    
    try:
        tm = CORE_MANAGER.get_core_service().table_manager
        tm.update_vrf_table(route_dist, prefix,
                            route_family=route_family, is_withdraw=True)
        # Send success response.
        return [{ROUTE_DISTINGUISHER: route_dist, PREFIX: prefix,
                 VRF_RF: route_family}]
    except BgpCoreError as e:
        raise PrefixError(desc=e)
753832
def version_router(self, request, response, api_version=None, versions={}, not_found=None, **kwargs):
        """"""
        request_version = self.determine_version(request, api_version)
        if request_version:
            request_version = int(request_version)
        versions.get(request_version or False, versions.get(None, not_found))(request, response,
                                                                              api_version=api_version,
                                                                              **kwargs)
106208
def UpdateHuntOutputPluginState(self, hunt_id, state_index, update_fn):
    """"""

    if hunt_id not in self.hunts:
      raise db.UnknownHuntError(hunt_id)

    try:
      state = rdf_flow_runner.OutputPluginState.FromSerializedString(
          self.hunt_output_plugins_states[hunt_id][state_index])
    except KeyError:
      raise db.UnknownHuntOutputPluginError(hunt_id, state_index)

    state.plugin_state = update_fn(state.plugin_state)

    self.hunt_output_plugins_states[hunt_id][
        state_index] = state.SerializeToString()

    return state.plugin_state
1336437
def _update_health_monitor_with_new_ips(route_spec, all_ips,
                                        q_monitor_ips):
    
    # Extract all the IP addresses from the route spec, unique and sorted.
    new_all_ips = \
        sorted(set(itertools.chain.from_iterable(route_spec.values())))
    if new_all_ips != all_ips:
        logging.debug("New route spec detected. Updating "
                      "health-monitor with: %s" %
                      ",".join(new_all_ips))
        # Looks like we have a new list of IPs
        all_ips = new_all_ips
        q_monitor_ips.put(all_ips)
    else:
        logging.debug("New route spec detected. No changes in "
                      "IP address list, not sending update to "
                      "health-monitor.")

    return all_ips
1160857
def _update_states(self, uid, states):
        
        #TODO: use try and catch all exceptions
        # test if uid exists
        if self.controllers[uid]:
            # test if states have correct lenght
            if len(states) == 14:
                old_states = self.controllers[uid][2]
                if old_states != states:
                    for key in range(14):
                        if int(old_states[key]) > int(states[key]):
                            e = Event(uid, E_KEYUP, key)
                            self.queue.put_nowait(e)
                        elif int(old_states[key]) < int(states[key]):
                            e = Event(uid, E_KEYDOWN, key)
                            self.queue.put_nowait(e)
                self.controllers[uid][2] = states
            self.controllers[uid][3] = time.time()
1283998
function findProxyName(moduleName, proxyName, uri, callback) {
    var base = path.basename(moduleName),
        proxyUri = path.join(uri, proxyName, base)

    fs.stat(proxyUri, checkIfProxyExists)

    function checkIfProxyExists(err, stat) {
        if (err) {
            if (proxyUri.substr(-3, 3) === ".js") {
                proxyUri = proxyUri.substr(0, proxyUri.length - 3)
            } else {
                proxyUri = proxyUri + ".js"
            }

            fs.stat(proxyUri, checkIfChangedUriHelped)
        } else {

            callback(null, path.relative(uri, proxyUri))
        }
    }

    function checkIfChangedUriHelped(err, stat) {
        if (err) {
            moduleName = path.dirname(moduleName)

            findProxyName(moduleName, proxyName, uri, callback)
        } else {

            if (proxyUri.substr(-3, 3) === ".js")  {
                callback(null, path.relative(uri, proxyUri))
            } else {
                findProxyObject(uri, path.relative(uri, proxyUri),
                    callback)
            }
        }
    }
}
659565
def where(self, **overrides):
        """"""
        route_data = self.route.copy()
        route_data.update(overrides)
        return self.__class__(**route_data)
378411
def update(self, config, force_cache=False, **kwargs):
        """"""
        # force = kwargs.pop('force', False)
        self.name = config['name']
        self.camera_id = str(config['id'])
        self.network_id = str(config['network_id'])
        self.serial = config['serial']
        self.motion_enabled = config['enabled']
        self.battery_voltage = config['battery_voltage']
        self.battery_state = config['battery_state']
        self.temperature = config['temperature']
        self.wifi_strength = config['wifi_strength']

        # Retrieve calibrated temperature from special endpoint
        resp = api.request_camera_sensors(self.sync.blink,
                                          self.network_id,
                                          self.camera_id)
        try:
            self.temperature_calibrated = resp['temp']
        except KeyError:
            self.temperature_calibrated = self.temperature
            _LOGGER.warning("Could not retrieve calibrated temperature.")

        # Check if thumbnail exists in config, if not try to
        # get it from the homescreen info in teh sync module
        # otherwise set it to None and log an error
        new_thumbnail = None
        if config['thumbnail']:
            thumb_addr = config['thumbnail']
        else:
            thumb_addr = self.get_thumb_from_homescreen()

        if thumb_addr is not None:
            new_thumbnail = "{}{}.jpg".format(self.sync.urls.base_url,
                                              thumb_addr)

        try:
            self.motion_detected = self.sync.motion[self.name]
        except KeyError:
            self.motion_detected = False

        clip_addr = None
        if self.name in self.sync.last_record:
            clip_addr = self.sync.last_record[self.name]['clip']
            self.last_record = self.sync.last_record[self.name]['time']
            self.clip = "{}{}".format(self.sync.urls.base_url,
                                      clip_addr)

        # If the thumbnail or clip have changed, update the cache
        update_cached_image = False
        if new_thumbnail != self.thumbnail or self._cached_image is None:
            update_cached_image = True
        self.thumbnail = new_thumbnail

        update_cached_video = False
        if self._cached_video is None or self.motion_detected:
            update_cached_video = True

        if new_thumbnail is not None and (update_cached_image or force_cache):
            self._cached_image = api.http_get(self.sync.blink,
                                              url=self.thumbnail,
                                              stream=True,
                                              json=False)
        if clip_addr is not None and (update_cached_video or force_cache):
            self._cached_video = api.http_get(self.sync.blink,
                                              url=self.clip,
                                              stream=True,
                                              json=False)
686316
def setRouteID(self, vehID, routeID):
        
        self._connection._sendStringCmd(
            tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_ROUTE_ID, vehID, routeID)
783203
function startDrones (pkg, done) {
    if (pkg.drones == 0) {
      return done();
    }

    var started = 0;

    async.whilst(function () {
      return started < pkg.drones;
    }, function (next) {
      started++;
      server.drone.start(pkg, next);
    }, done);
  }
757068
def update(self):
        """"""
        self._controller.update(self._id, wake_if_asleep=False)
        data = self._controller.get_state_params(self._id)
        if data:
            self.__odometer = data['odometer']
        data = self._controller.get_gui_params(self._id)
        if data:
            if data['gui_distance_units'] == "mi/hr":
                self.measurement = 'LENGTH_MILES'
            else:
                self.measurement = 'LENGTH_KILOMETERS'
            self.__rated = (data['gui_range_display'] == "Rated")
1293149
def get_controller_state(self):
        """"""
        dpos = self.pos - self.last_pos
        self.last_pos = np.array(self.pos)
        return dict(
            dpos=dpos,
            rotation=self.rotation,
            grasp=int(self.grasp),
            reset=self._reset_state,
        )
352784
def find(self, resource_id, query=None):
        

        return self.proxy.find(resource_id, query=query)
465673
function updateSnapshot(app, uid, cb) {
  logger.debug('updateSnapshot entry');

  app.models.snapshot.findOne(
    { where: { current: 'true' } },
    function(err, instance) {
      if (err) {
        // fall through assuming there was no current
      } else if (instance) {
        instance.updateAttributes(
          { current: 'false' },
          function(err, instance) {
            if (err) {
              // fall through assuming instance was deleted
            }
          });
        releaseSnapshot(app, instance.id);
      }
    });

  app.models.snapshot.findById(uid, function(err, instance) {
    if (err) {
      logger.debug('updateSnapshot error(1)');
      cb(err);
      return;
    }

    instance.updateAttributes(
      { current: 'true' },
      function(err, instance) {
        if (err) {
          logger.debug('updateSnapshot error(2)');
          cb(err);
          return;
        }
        logger.debug('updateSnapshot exit');
        cb();
      });
  });
}
1213301
def update_router(self, router, body=None):
        """"""
        return self.put(self.router_path % (router), body=body)