Determine which sector was scanned
490563
def _get_sector(self, channel, nlines, ncols):
        """"""
        if self._is_vis(channel):
            margin = 100
            sectors_ref = self.vis_sectors
        else:
            margin = 50
            sectors_ref = self.ir_sectors

        for (nlines_ref, ncols_ref), sector in sectors_ref.items():
            if np.fabs(ncols - ncols_ref) < margin and \
                    np.fabs(nlines - nlines_ref) < margin:
                return sector

        return UNKNOWN_SECTOR
1024518
def scanline_positions
      scanline_pos = [0]
      amount = @filtered_data.size
      @interlace_pass_count = []
      if self.interlaced?
        # Adam7
        # Pass 1
        v = 1 + (@width / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 2
        v = 1 + ((@width - 4) / 8.0).ceil * @sample_size
        (@height / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 3
        v = 1 + (@width / 4.0).ceil * @sample_size
        ((@height - 4) / 8.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 4
        v = 1 + ((@width - 2) / 4.0).ceil * @sample_size
        (@height / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 5
        v = 1 + (@width / 2.0).ceil * @sample_size
        ((@height - 2) / 4.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 6
        v = 1 + ((@width - 1) / 2.0).ceil * @sample_size
        (@height / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        @interlace_pass_count << scanline_pos.size
        # Pass 7
        v = 1 + @width * @sample_size
        ((@height - 1) / 2.0).ceil.times do
          scanline_pos << scanline_pos.last + v
        end
        scanline_pos.pop  # no need to keep last position
      end
      loop do
        v = scanline_pos.last + (1 + @width * @sample_size)
        break if v >= amount
        scanline_pos << v
      end
      scanline_pos
    end
1305526
def _Parse(self):
    """"""
    root_file_entry = self._file_system.GetRootFileEntry()
    tsk_volume = self._file_system.GetTSKVolume()
    self.bytes_per_sector = tsk_partition.TSKVolumeGetBytesPerSector(tsk_volume)

    for sub_file_entry in root_file_entry.sub_file_entries:
      tsk_vs_part = sub_file_entry.GetTSKVsPart()
      start_sector = tsk_partition.TSKVsPartGetStartSector(tsk_vs_part)
      number_of_sectors = tsk_partition.TSKVsPartGetNumberOfSectors(tsk_vs_part)

      if start_sector is None or number_of_sectors is None:
        continue

      if tsk_partition.TSKVsPartIsAllocated(tsk_vs_part):
        volume = TSKVolume(sub_file_entry, self.bytes_per_sector)
        self._AddVolume(volume)

      volume_extent = volume_system.VolumeExtent(
          start_sector * self.bytes_per_sector,
          number_of_sectors * self.bytes_per_sector)

      self._sections.append(volume_extent)
283720
def GetUnscannedSubNode(self):
    
    if not self.sub_nodes and not self.scanned:
      return self

    for sub_node in self.sub_nodes:
      result = sub_node.GetUnscannedSubNode()
      if result:
        return result

    return None
944234
def _identify(self, dataframe):
        """"""
        idx = ((dataframe[self.channels[0]] <= self.vert[1]) &
               (dataframe[self.channels[0]] >= self.vert[0]))

        if self.region == 'out':
            idx = ~idx

        return idx
1201770
def desc(self):
        """"""
        # Auto Away (1) - Location - Enabled
        active = 'inactive'
        if self.is_active:
            active = 'active'

        return '{0} (ID: {1}) - {2} - {3}'.format(
            self.name, self.automation_id, self.type, active)
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:]))
434022
def _verify_sector_identifier(self, request):
        
        si_url = request["sector_identifier_uri"]
        try:
            res = self.endpoint_context.httpc.get(si_url)
        except Exception as err:
            logger.error(err)
            res = None

        if not res:
            raise InvalidSectorIdentifier("Couldn't read from sector_identifier_uri")

        logger.debug("sector_identifier_uri => %s", sanitize(res.text))

        try:
            si_redirects = json.loads(res.text)
        except ValueError:
            raise InvalidSectorIdentifier(
                "Error deserializing sector_identifier_uri content")

        if "redirect_uris" in request:
            logger.debug("redirect_uris: %s", request["redirect_uris"])
            for uri in request["redirect_uris"]:
                if uri not in si_redirects:
                    raise InvalidSectorIdentifier(
                        "redirect_uri missing from sector_identifiers")

        return si_redirects, si_url
933168
def _sectors(self, ignore_chunk=None):
        
        sectorsize = self._bytes_to_sector(self.size)
        sectors = [[] for s in range(sectorsize)]
        sectors[0] = True # locations
        sectors[1] = True # timestamps
        for m in self.metadata.values():
            if not m.is_created():
                continue
            if ignore_chunk == m:
                continue
            if m.blocklength and m.blockstart:
                blockend = m.blockstart + max(m.blocklength, m.requiredblocks())
                # Ensure 2 <= b < sectorsize, as well as m.blockstart <= b < blockend
                for b in range(max(m.blockstart, 2), min(blockend, sectorsize)):
                    sectors[b].append(m)
        return sectors
428936
def scan_results(self, obj):
        """"""

        avail_network_list = pointer(WLAN_AVAILABLE_NETWORK_LIST())
        self._wlan_get_available_network_list(self._handle,
            byref(obj['guid']), byref(avail_network_list))
        networks = cast(avail_network_list.contents.Network,
                     POINTER(WLAN_AVAILABLE_NETWORK))

        self._logger.debug("Scan found %d networks.",
            avail_network_list.contents.dwNumberOfItems)

        network_list = []
        for i in range(avail_network_list.contents.dwNumberOfItems):

            if networks[i].dot11BssType == 1 and networks[i].bNetworkConnectable :

                ssid = ''
                for j in range(networks[i].dot11Ssid.uSSIDLength):

                    if networks[i].dot11Ssid.ucSSID != b'':
                        ssid += "%c" % networks[i].dot11Ssid.ucSSID[j]

                bss_list = pointer(WLAN_BSS_LIST())
                self._wlan_get_network_bss_list(self._handle,
                    byref(obj['guid']), byref(bss_list), networks[i].dot11Ssid, networks[i].bSecurityEnabled)
                bsses = cast(bss_list.contents.wlanBssEntries,
                             POINTER(WLAN_BSS_ENTRY))

                if networks[i].bSecurityEnabled:
                    akm = self._get_akm(networks[i].dot11DefaultCipherAlgorithm)
                    auth_alg = self._get_auth_alg(networks[i].dot11DefaultAuthAlgorithm)
                else:
                    akm = [AKM_TYPE_NONE]
                    auth_alg = [AUTH_ALG_OPEN]

                for j in range(bss_list.contents.dwNumberOfItems):
                    network = Profile()

                    network.ssid = ssid

                    network.bssid = ''
                    for k in range(6):
                        network.bssid += "%02x:" % bsses[j].dot11Bssid[k]

                    network.signal = bsses[j].lRssi
                    network.freq = bsses[j].ulChCenterFrequency
                    network.auth = auth_alg
                    network.akm = akm
                    network_list.append(network)

        return network_list
890825
def DirScanner(**kw):
    """"""
    kw['node_factory'] = SCons.Node.FS.Entry
    kw['recursive'] = only_dirs
    return SCons.Scanner.Base(scan_on_disk, "DirScanner", **kw)
1248038
def sample_counters(mc, system_info):
    """"""
    return {
        (x, y): mc.get_router_diagnostics(x, y) for (x, y) in system_info
    }
797505
private ParsedResultAccumulator getBestCostPlanForEphemeralScans(List<StmtEphemeralTableScan> scans) {
        int nextPlanId = m_planSelector.m_planId;
        boolean orderIsDeterministic = true;
        boolean hasSignificantOffsetOrLimit = false;
        String contentNonDeterminismMessage = null;
        for (StmtEphemeralTableScan scan : scans) {
            if (scan instanceof StmtSubqueryScan) {
                nextPlanId = planForParsedSubquery((StmtSubqueryScan)scan, nextPlanId);
                // If we can't plan this, then give up.
                if (((StmtSubqueryScan) scan).getBestCostPlan() == null) {
                    return null;
                }
            }
            else if (scan instanceof StmtCommonTableScan) {
                nextPlanId = planForCommonTableQuery((StmtCommonTableScan)scan, nextPlanId);
                if (((StmtCommonTableScan) scan).getBestCostBasePlan() == null) {
                    return null;
                }
            }
            else {
                throw new PlanningErrorException("Unknown scan plan type.");
            }
            orderIsDeterministic = scan.isOrderDeterministic(orderIsDeterministic);
            contentNonDeterminismMessage = scan.contentNonDeterminismMessage(contentNonDeterminismMessage);
            hasSignificantOffsetOrLimit = scan.hasSignificantOffsetOrLimit(hasSignificantOffsetOrLimit);
        }
        // need to reset plan id for the entire SQL
        m_planSelector.m_planId = nextPlanId;

        return new ParsedResultAccumulator(orderIsDeterministic,
                                           hasSignificantOffsetOrLimit,
                                           contentNonDeterminismMessage);
    }
1230703
def sector_code_name(self):
        
        try:
            return self.__dict__["sector_code_name"]
        except (KeyError, ValueError):
            raise AttributeError(
                "Instrument(order_book_id={}) has no attribute 'sector_code_name' ".format(self.order_book_id)
            )
867057
def prescan(self):
        """"""
        if self.to_scan:
            list(map(self.scan_url, self.to_scan))
        self.to_scan = None
199621
def scan(self):
        """"""

        log.debug("scanning machine: %s..." % self.name)

        deployed = set()
        services = yield self.client.get_children(self.path + "/services")

        for name in services:
            log.debug("checking service: '%s'..." % name)

            try:
                value, metadata = yield self.client.get(
                    self.path + "/services/" + name + "/machines"
                    )
            except NoNodeException:
                log.warn(
                    "missing machines declaration for service: %s." %
                    name
                    )
                machines = []
            else:
                machines = json.loads(value)

            if machines:
                log.debug("machines: %s." % ", ".join(machines))

                if self.name in machines:
                    deployed.add(name)
            else:
                log.debug("service not configured for any machine.")

        count = len(deployed)
        log.debug("found %d service(s) configured for this machine." % count)

        running = yield self.client.get_children(
            self.path + "/machines/" + self.name
            )

        self.stopped = deployed - set(running)

        if self.stopped:
            log.debug("services not running: %s." % ", ".join(
                map(repr, self.stopped)))
        elif running:
            log.debug("all services are up.")
1161537
def get_sections_2dnt(self, sec2d_go):
        """"""
        return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go]