Reads all devices from the database.  Creates new filterchains and removes old ones
        
        TODO: currently this is broken: if user changes any other field than the ip address, the cameras don't get updated
187957
def update(self):
        
        raise(AssertionError("out of date"))
        
        new_ids = []
        old_ids = []
        
        # collect old ip addresses
        for chain in self.chains:
            if (self.verbose): print(self.pre, "old :", chain, chain.get__id(), chain.get_address(), chain._id)
            old_ids.append(chain.get__id())
            
        # collect devices
        devices = []
        for dic in self.datamodel.camera_collection.get():
            if (self.verbose): print(self.pre, "update : dic", dic)
            if (dic["classname"] == DataModel.RTSPCameraRow.__name__):
                devices.append(dic)
            
        devices_by_id={}
        for dic in devices: # DataModel.RTSPCameraRow instances
            _id = dic["_id"]
            new_ids.append(_id)
            devices_by_id[_id] = dic
        
        if (self.verbose):
            print(self.pre, "update : new_ids =", new_ids)
            print(self.pre, "update : old_ids =", old_ids)
        
        add_list = list(set(new_ids).difference(set(old_ids))) # cams to be added
        rem_list = list(set(old_ids).difference(set(new_ids))) # cams to be removed
        
        if (self.verbose):
            print(self.pre, "update : add_list =", add_list)
            print(self.pre, "update : rem_list =", rem_list)
        
        # purge removed chains
        for i, chain in enumerate(self.chains):
            if (chain.get__id() in rem_list):
                chain_ = self.chains.pop(i)
                if (self.verbose): print(self.pre, "closing chain", chain_)
                chain_.close()
        
        # add new chains
        for new_address in add_list:
            dic = devices_by_id[new_address]
            chain = ManagedFilterchain( # decoding and branching the stream happens here
                livethread  = self.livethread,
                openglthreads
                            = self.gpu_handler.openglthreads,
                address     = DataModel.RTSPCameraRow.getMainAddressFromDict(dic),
                slot        = dic["slot"],
                _id         = dic["_id"],
                # affinity    = a,
                msreconnect = 10000,
                verbose = True
            )
            if (self.verbose): print(self.pre, "adding chain", chain)
            self.chains.append(chain)
755038
def clear_data(self):
        
        # Removes the item from filesystem and resets URL to ''
        url = self.get_url()
        # try to clear from payload first, in case that fails we won't mess with AWS
        self._payload.clear_url()
        os.remove(url)
833868
def delete_devices(self, auth_body, devices):
        
        content = {
            "auth": auth_body,
            "devices": devices
        }
        return self._send("POST", "/delete_devices", content=content)
1307254
def device_filter(self):
        
        if isinstance(self._device_filter, str):
            return self._decode_query(self._device_filter)
        return self._device_filter
722490
def clean(self):
        ''''''
        if not self.urlhash or 'url' in self._get_changed_fields():
            self.urlhash = hash_url(self.url)
        super(Reuse, self).clean()
859712
function readSingleAddress(conn, handleAddress){
	readSingleWallet(conn, function(wallet_id){
		conn.query("SELECT address FROM my_addresses WHERE wallet=?", [wallet_id], function(rows){
			if (rows.length === 0)
				throw Error("no addresses");
			if (rows.length > 1)
				throw Error("more than 1 address");
			handleAddress(rows[0].address);
		});
	})
}
646462
@Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
                    ServletException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;

        for (String path : mediaTypes.keySet()) {
            if (matches(httpServletRequest, path)) {
                response.setContentType(mediaTypes.get(path));
                break;
            }
        }
        chain.doFilter(request, response);
    }
26082
def update(self, equipments):
        

        data = {'equipments': equipments}
        equipments_ids = [str(env.get('id')) for env in equipments]

        return super(ApiV4Equipment, self).put('api/v4/equipment/%s/' %
                                               ';'.join(equipments_ids), data)
137729
def get_devices(self, refresh=False, generic_type=None):
        """"""
        _LOGGER.info("Updating all devices...")
        if refresh or self._devices is None:
            if self._devices is None:
                self._devices = {}

            responseObject = self.get_sensors()
            if (responseObject and
                    not isinstance(responseObject, (tuple, list))):
                responseObject = responseObject

            for deviceJson in responseObject:
                # Attempt to reuse an existing device
                device = self._devices.get(deviceJson['name'])

                # No existing device, create a new one
                if device:
                    device.update(deviceJson)
                else:
                    device = newDevice(deviceJson, self)

                    if not device:
                        _LOGGER.info('Device is unknown')
                        continue

                    self._devices[device.device_id] = device

            # We will be treating the Lupusec panel itself as an armable device.
            panelJson = self.get_panel()
            _LOGGER.debug("Get the panel in get_devices: %s", panelJson)

            self._panel.update(panelJson)

            alarmDevice = self._devices.get('0')

            if alarmDevice:
                alarmDevice.update(panelJson)
            else:
                alarmDevice = ALARM.create_alarm(panelJson, self)
                self._devices['0'] = alarmDevice

            # Now we will handle the power switches
            switches = self.get_power_switches()
            _LOGGER.debug(
                'Get active the power switches in get_devices: %s', switches)

            for deviceJson in switches:
                # Attempt to reuse an existing device
                device = self._devices.get(deviceJson['name'])

                # No existing device, create a new one
                if device:
                    device.update(deviceJson)
                else:
                    device = newDevice(deviceJson, self)
                    if not device:
                        _LOGGER.info('Device is unknown')
                        continue
                    self._devices[device.device_id] = device

        if generic_type:
            devices = []
            for device in self._devices.values():
                if (device.type is not None and
                        device.type in generic_type[0]):
                    devices.append(device)
            return devices

        return list(self._devices.values())
844036
def read(self, include_deleted=False):
        """"""
        if is_soft_delete() and not include_deleted:
            return self.filter(unread=False, deleted=False)

        # When SOFT_DELETE=False, developers are supposed NOT to touch 'deleted' field.
        # In this case, to improve query performance, don't filter by 'deleted' field
        return self.filter(unread=False)
282892
@ReadOperation
    public Set<? extends MultifactorAuthenticationTrustRecord> devices() {
        val onOrAfter = expireRecordsByDate();
        return this.mfaTrustEngine.get(onOrAfter);
    }
319579
def get_cameras(self):
        """"""
        response = api.request_homescreen(self)
        try:
            all_cameras = {}
            for camera in response['cameras']:
                camera_network = str(camera['network_id'])
                camera_name = camera['name']
                camera_id = camera['id']
                camera_info = {'name': camera_name, 'id': camera_id}
                if camera_network not in all_cameras:
                    all_cameras[camera_network] = []

                all_cameras[camera_network].append(camera_info)
            return all_cameras
        except KeyError:
            _LOGGER.error("Initialization failue. Could not retrieve cameras.")
            return {}
697889
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def check_last_ip(app):
        return LastIpCheck(app, conf)
    return check_last_ip
244558
def parse_devices(self):
        """"""
        devices = []
        for device in self._channel_dict["devices"]:
            devices.append(Device(device, self._is_sixteen_bit, self._ignore_list))
        return devices
478354
def get_all_devices_in_portal(self):
        
        rids = self.get_portal_by_name(
                        self.portal_name()
                )[2][1]['info']['aliases']

        # print("RIDS: {0}".format(rids))
        device_rids = [ rid.strip() for rid in rids ]

        blocks_of_ten = [ device_rids[x:x+10] for x in range(0, len(device_rids), 10) ]
        devices = []
        for block_of_ten in blocks_of_ten:
            retval = self.get_multiple_devices(block_of_ten)
            if retval is not None:
                devices.extend( retval )
            else:
                print("Not adding to device list: {!r}".format(retval))

        # Parse 'meta' key's raw string values for each device
        for device in devices:
            dictify_device_meta(device)

        return devices
749806
def get_all_connected_devices(self):
        
        self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
        self.bbox_url.set_api_name(BboxConstant.API_HOSTS, None)
        api = BboxApiCall(self.bbox_url, BboxConstant.HTTP_METHOD_GET, None,
                          self.bbox_auth)
        resp = api.execute_api_request()
        return resp.json()[0]["hosts"]["list"]
730974
def lookup_camera_by_id(self, device_id):
        """"""
        camera = list(filter(
            lambda cam: cam.device_id == device_id, self.cameras))[0]
        if camera:
            return camera
        return None