Scan for devices multiple times.
324270
async def scan_for_devices_multi_run(self, runs=2):
        """"""
        run = 1
        master = {}
        while run < runs + 1:
            await self.scan_for_devices()
            await self.get_scan_result()
            if master is None:
                for device in self._devices:
                    mac = device['mac_address']
                    master[mac] = {}
                    master[mac]['rssi'] = device['rssi']
                    master[mac]['device_class'] = device['device_class']
                    master[mac]['name'] = device['name']
                    master[mac]['device_type'] = device['device_type']
                    master[mac]['count'] = 1
            else:
                for device in self._devices:
                    mac = device['mac_address']
                    if master.get(mac, False):
                        master[mac]['rssi'] = device['rssi']
                        master[mac]['count'] = str(1 + 1)
                    else:
                        master[mac] = {}
                        master[mac]['rssi'] = device['rssi']
                        master[mac]['device_class'] = device['device_class']
                        master[mac]['name'] = device['name']
                        master[mac]['device_type'] = device['device_type']
                        master[mac]['count'] = 1
            run = run + 1
            result = []
            for device in master:
                if int(master[device]['count']) > 1:
                    result.append(master[device])
        self._devices = result
1181859
def scanning(reducer, init=UNSET):
    """"""

    reducer2 = reducer

    def scanning_transducer(reducer):
        return Scanning(reducer, reducer2, init)

    return scanning_transducer
868404
def scan_for_devices(timeout: float) -> List[Tuple[str, str]]:
        """"""
        from bluepy.btle import Scanner

        scanner = Scanner()
        result = []
        for device in scanner.scan(timeout):
            result.append((device.addr, device.getValueText(9)))
        return result
1312893
async def get_devices(self):
        """"""
        data = await self.api("devices")
        if self.connected and self.authenticated:
            self._devices = data
        else:
            self._devices = self._devices
        _LOGGER.debug(self._devices)
632668
async def scan_for_apple_tvs(loop, timeout=5, abort_on_found=False,
                             device_ip=None, only_usable=True,
                             protocol=None):
    """"""
    semaphore = asyncio.Semaphore(value=0, loop=loop)
    listener = _ServiceListener(
        loop, abort_on_found, device_ip, protocol, semaphore)
    zeroconf = Zeroconf()
    try:
        ServiceBrowser(zeroconf, HOMESHARING_SERVICE, listener)
        ServiceBrowser(zeroconf, DEVICE_SERVICE, listener)
        ServiceBrowser(zeroconf, MEDIAREMOTE_SERVICE, listener)
        ServiceBrowser(zeroconf, AIRPLAY_SERVICE, listener)
        _LOGGER.debug('Discovering devices for %d seconds', timeout)
        await asyncio.wait_for(semaphore.acquire(), timeout, loop=loop)
    except concurrent.futures.TimeoutError:
        pass  # Will happen when timeout occurs (totally normal)
    finally:
        zeroconf.close()

    def _should_include(atv):
        if not only_usable:
            return True

        return atv.is_usable()

    return list(filter(_should_include, listener.found_devices.values()))
113995
def _find_devices():
    
    ret = []

    logger.info('Looking for devices....')

    if pyusb1:
        for d in usb.core.find(idVendor=USB_VID, idProduct=USB_PID, find_all=1,
                               backend=pyusb_backend):
            ret.append(d)
    else:
        busses = usb.busses()
        for bus in busses:
            for device in bus.devices:
                if device.idVendor == USB_VID:
                    if device.idProduct == USB_PID:
                        ret += [device, ]

    return ret
137122
def _match_device(self):
        """"""
        for device in self.manager.all_devices:
            if (device.get_char_device_path() ==
                    self._character_device_path):
                self.device = device
                device.leds.append(self)
                break
1017435
public void scanDevices()
    {
        for (int deviceId : inputManager.getInputDeviceIds()) {
            addDevice(deviceId);
        }
        for (GVRGearCursorController controller : gearCursorControllers)
        {
            cache.put(CONTROLLER_CACHED_KEY + controller.getControllerID(), controller);
        }
    }
88812
def get_multiple_devices(self, rids):
        
        headers = {
                'User-Agent': self.user_agent(),
                'Content-Type': self.content_type()
        }
        headers.update(self.headers())

        url = self.portals_url()+'/users/_this/devices/' + str(rids).replace("'", "").replace(' ','')
        # print("URL: {0}".format(url))
        r = requests.get(   url,
                            headers=headers,
                            auth=self.auth())
    
        if HTTP_STATUS.OK == r.status_code:
            # TODO: loop through all rids and fix 'meta' to be dict like add_device and get_device do
            return r.json()
        else:
            print("get_multiple_devices: Something went wrong: <{0}>: {1}".format(
                        r.status_code, r.reason))
            r.raise_for_status()
913356
public void scan() {

		WebcamDiscoveryListener[] listeners = Webcam.getDiscoveryListeners();

		List<WebcamDevice> tmpnew = driver.getDevices();
		List<WebcamDevice> tmpold = null;

		try {
			tmpold = getDevices(getWebcams(Long.MAX_VALUE, TimeUnit.MILLISECONDS));
		} catch (TimeoutException e) {
			throw new WebcamException(e);
		}

		// convert to linked list due to O(1) on remove operation on
		// iterator versus O(n) for the same operation in array list

		List<WebcamDevice> oldones = new LinkedList<WebcamDevice>(tmpold);
		List<WebcamDevice> newones = new LinkedList<WebcamDevice>(tmpnew);

		Iterator<WebcamDevice> oi = oldones.iterator();
		Iterator<WebcamDevice> ni = null;

		WebcamDevice od = null; // old device
		WebcamDevice nd = null; // new device

		// reduce lists

		while (oi.hasNext()) {

			od = oi.next();
			ni = newones.iterator();

			while (ni.hasNext()) {

				nd = ni.next();

				// remove both elements, if device name is the same, which
				// actually means that device is exactly the same

				if (nd.getName().equals(od.getName())) {
					ni.remove();
					oi.remove();
					break;
				}
			}
		}

		// if any left in old ones it means that devices has been removed
		if (oldones.size() > 0) {

			List<Webcam> notified = new ArrayList<Webcam>();

			for (WebcamDevice device : oldones) {
				for (Webcam webcam : webcams) {
					if (webcam.getDevice().getName().equals(device.getName())) {
						notified.add(webcam);
						break;
					}
				}
			}

			setCurrentWebcams(tmpnew);

			for (Webcam webcam : notified) {
				notifyWebcamGone(webcam, listeners);
				webcam.dispose();
			}
		}

		// if any left in new ones it means that devices has been added
		if (newones.size() > 0) {

			setCurrentWebcams(tmpnew);

			for (WebcamDevice device : newones) {
				for (Webcam webcam : webcams) {
					if (webcam.getDevice().getName().equals(device.getName())) {
						notifyWebcamFound(webcam, listeners);
						break;
					}
				}
			}
		}
	}
1097965
def start_scan(self, scan_id, targets, parallel=1):
        

        os.setsid()
        multiscan_proc = []
        logger.info("%s: Scan started.", scan_id)
        target_list = targets
        if target_list is None or not target_list:
            raise OSPDError('Erroneous targets list', 'start_scan')

        for index, target in enumerate(target_list):
            while len(multiscan_proc) >= parallel:
                progress = self.calculate_progress(scan_id)
                self.set_scan_progress(scan_id, progress)
                multiscan_proc = self.check_pending_target(scan_id,
                                                           multiscan_proc)
                time.sleep(1)

            #If the scan status is stopped, does not launch anymore target scans
            if self.get_scan_status(scan_id) == ScanStatus.STOPPED:
                return

            logger.info("%s: Host scan started on ports %s.", target[0], target[1])
            scan_process = multiprocessing.Process(target=self.parallel_scan,
                                                   args=(scan_id, target[0]))
            multiscan_proc.append((scan_process, target[0]))
            scan_process.start()
            self.set_scan_status(scan_id, ScanStatus.RUNNING)

        # Wait until all single target were scanned
        while multiscan_proc:
            multiscan_proc = self.check_pending_target(scan_id, multiscan_proc)
            if multiscan_proc:
                progress = self.calculate_progress(scan_id)
                self.set_scan_progress(scan_id, progress)
            time.sleep(1)

        # Only set the scan as finished if the scan was not stopped.
        if self.get_scan_status(scan_id) != ScanStatus.STOPPED:
            self.finish_scan(scan_id)
435931
def scan():
    
    available = []
    for i in range(256):
        try:
            s = serial.Serial('COM'+str(i))
            available.append((i, s.portstr))
            s.close()
        except serial.SerialException:
            pass
    return available
744477
def _scan(positions):
    """"""
    scores = []
    for start in range(0, len(positions) - 17, 5):
        end = start = 17
        scores.add(_enrichment(positions[start:end], positions[:start], positions[end:]))
587232
async def scan(self, cursor=0, match=None, count=None):
        
        pieces = [cursor]
        if match is not None:
            pieces.extend([b('MATCH'), match])
        if count is not None:
            pieces.extend([b('COUNT'), count])
        return await self.execute_command('SCAN', *pieces)
1305904
private Iterator<MultiTableScanResult> scanMultiTableRows(
            final TableSet tables, final DeltaPlacement placement, final ByteBufferRange rowRange,
            final LimitCounter limit, final boolean includeDroppedTables, final boolean includeMirrorTables,
            final int largeRowThreshold, final ReadConsistency consistency, @Nullable final Instant cutoffTime) {

        // Avoiding pinning multiple decoded rows into memory at once.
        return limit.limit(new AbstractIterator<MultiTableScanResult>() {
            private PeekingIterator<Row<ByteBuffer, DeltaKey>> _iter = Iterators.peekingIterator(
                    rowScan(placement, rowRange, _maxColumnsRange, LimitCounter.max(), consistency));

            private long _lastTableUuid = -1;
            private AstyanaxTable _table = null;
            private boolean _droppedTable;
            private boolean _primaryTable;

            @Override
            protected MultiTableScanResult computeNext() {
                while (_iter.hasNext()) {
                    Row<ByteBuffer, DeltaKey> row = _iter.next();
                    ColumnList<DeltaKey> rowColumns = row.getColumns();

                    // Convert the results into a Record object, lazily fetching the rest of the columns as necessary.
                    ByteBuffer rowKey = row.getRawKey();

                    long tableUuid = AstyanaxStorage.getTableUuid(rowKey);
                    if (_lastTableUuid != tableUuid) {
                        _lastTableUuid = tableUuid;
                        try {
                            _table = (AstyanaxTable) tables.getByUuid(tableUuid);
                        } catch (UnknownTableException e) {
                            _table = AstyanaxTable.createUnknown(tableUuid, placement, e.getTable());
                        } catch (DroppedTableException e) {
                            _table = AstyanaxTable.createUnknown(tableUuid, placement, e.getPriorTable());
                        }
                        _droppedTable = _table.isUnknownTable();
                        _primaryTable = _table.getReadStorage().hasUUID(tableUuid);
                    }

                    // Skip dropped and mirror tables if configured
                    if ((!includeDroppedTables && _droppedTable) || (!includeMirrorTables && !_primaryTable)) {
                        _iter = skipToNextTable(tableUuid);
                        continue;
                    }

                    int shardId = AstyanaxStorage.getShardId(rowKey);
                    String key = AstyanaxStorage.getContentKey(rowKey);
                    Record record = newRecord(new Key(_table, key), rowKey, rowColumns, largeRowThreshold, consistency, cutoffTime);
                    return new MultiTableScanResult(rowKey, shardId, tableUuid, _droppedTable, record);
                }

                return endOfData();
            }

            private PeekingIterator<Row<ByteBuffer, DeltaKey>> skipToNextTable(long tableUuid) {
                // Iterate over the next 50 rows first to check for a table switch.  This avoids starting a new range
                // query if the number of rows in the undesired table is small.
                int skipLimit = 50;
                Row<ByteBuffer, DeltaKey> row = null;

                while (skipLimit != 0 && _iter.hasNext()) {
                    row = _iter.peek();
                    long nextTableUuid = AstyanaxStorage.getTableUuid(row.getRawKey());
                    if (nextTableUuid != tableUuid) {
                        // This is the first row of a new table
                        return _iter;
                    } else {
                        _iter.next();
                        skipLimit -= 1;
                    }
                }

                if (_iter.hasNext()) {
                    // Skip the table entirely by starting a new query on the next possible table
                    assert row != null;
                    int shardId = AstyanaxStorage.getShardId(row.getRawKey());
                    ByteBuffer nextPossibleTableStart = AstyanaxStorage.getRowKeyRaw(shardId, tableUuid + 1, "");
                    ByteBuffer end = rowRange.getEnd();

                    if (AstyanaxStorage.compareKeys(nextPossibleTableStart, end) < 0) {
                        // We haven't reached the last end boundary of the original range scan
                        ByteBufferRange updatedRange = new ByteBufferRangeImpl(nextPossibleTableStart, end, -1, false);
                        return Iterators.peekingIterator(
                                rowScan(placement, updatedRange, _maxColumnsRange, LimitCounter.max(), consistency));
                    }
                }

                return Iterators.peekingIterator(Iterators.<Row<ByteBuffer, DeltaKey>>emptyIterator());
            }
        });
    }
1142882
function (successCallback, errorCallback) {
			if (!winble.deviceManager.isScanning) {
				winble.deviceManager.scanSuccessCallback = successCallback;
				winble.deviceManager.scanErrorCallback = errorCallback;
				winble.deviceManager.isScanning = true;
				setTimeout(function () {
					winble.deviceManager.scanDevices(successCallback, errorCallback);
				}, 500);
			}
		}
236139
def get_device(self, device_id, refresh=False):
        """"""
        if self._devices is None:
            self.get_devices()
            refresh = False

        device = self._devices.get(device_id)

        if device and refresh:
            device.refresh()

        return device