Checks for rooms we've joined and which partner isn't health-checked and leave.

        **MUST** be called from a context that holds the `_account_data_lock`.
324778
def _leave_unused_rooms(self, _address_to_room_ids: Dict[AddressHex, List[_RoomID]]):
        
        _msg = '_leave_unused_rooms called without account data lock'
        assert self._account_data_lock.locked(), _msg

        # TODO: Remove the next five lines and check if transfers start hanging again
        self._client.set_account_data(
            'network.raiden.rooms',  # back from cast in _set_room_id_for_address
            cast(Dict[str, Any], _address_to_room_ids),
        )
        return

        # cache in a set all whitelisted addresses
        whitelisted_hex_addresses: Set[AddressHex] = {
            to_checksum_address(address)
            for address in self._address_mgr.known_addresses
        }

        keep_rooms: Set[_RoomID] = set()

        for address_hex, room_ids in list(_address_to_room_ids.items()):
            if not room_ids:  # None or empty
                room_ids = list()
            if not isinstance(room_ids, list):  # old version, single room
                room_ids = [room_ids]

            if address_hex not in whitelisted_hex_addresses:
                _address_to_room_ids.pop(address_hex)
                continue

            counters = [0, 0]  # public, private
            new_room_ids: List[_RoomID] = list()

            # limit to at most 2 public and 2 private rooms, preserving order
            for room_id in room_ids:
                if room_id not in self._client.rooms:
                    continue
                elif self._client.rooms[room_id].invite_only is None:
                    new_room_ids.append(room_id)  # not known, postpone cleaning
                elif counters[self._client.rooms[room_id].invite_only] < 2:
                    counters[self._client.rooms[room_id].invite_only] += 1
                    new_room_ids.append(room_id)  # not enough rooms of this type yet
                else:
                    continue  # enough rooms, leave and clean

            keep_rooms |= set(new_room_ids)
            if room_ids != new_room_ids:
                _address_to_room_ids[address_hex] = new_room_ids

        rooms: List[Tuple[_RoomID, Room]] = list(self._client.rooms.items())

        self.log.debug(
            'Updated address room mapping',
            address_to_room_ids=_address_to_room_ids,
        )
        self._client.set_account_data('network.raiden.rooms', _address_to_room_ids)

        def leave(room: Room):
            """A race between /leave and /sync may remove the room before
            del on _client.rooms key. Suppress it, as the end result is the same: no more room"""
            try:
                self.log.debug('Leaving unused room', room=room)
                return room.leave()
            except KeyError:
                return True

        for room_id, room in rooms:
            if room_id in {groom.room_id for groom in self._global_rooms.values() if groom}:
                # don't leave global room
                continue
            if room_id not in keep_rooms:
                greenlet = self._spawn(leave, room)
                greenlet.name = (
                    f'MatrixTransport.leave '
                    f'node:{pex(self._raiden_service.address)} '
                    f'user_id:{self._user_id}'
                )
821813
def run_check(participants, config, reference_time):
    
    recruiters_with_late_participants = defaultdict(list)
    for p in participants:
        timeline = ParticipationTime(p, reference_time, config)
        if timeline.is_overdue:
            print(
                "Error: participant {} with status {} has been playing for too "
                "long - their recruiter will be notified.".format(p.id, p.status)
            )
            recruiters_with_late_participants[p.recruiter_id].append(p)

    for recruiter_id, participants in recruiters_with_late_participants.items():
        recruiter = recruiters.by_name(recruiter_id)
        recruiter.notify_duration_exceeded(participants, reference_time)
743612
private void checkDependencies() {
    if (basedOnResult != null) {
      if (!input.isComplete() || !algs.isComplete() || basedOnResult.get() != algs.getAlgorithmStep().getResult()) {
        // We've become invalidated, notify.
        basedOnResult = null;
        firePanelUpdated();
      }
    }
  }
192091
function isLoggedInAsync(cb) {
      if (currentUser.hasOwnProperty('$promise')) {
        currentUser.$promise.then(function () {
          cb(true);
        }).catch(function () {
          cb(false);
        });
      } else if (currentUser.hasOwnProperty('role')) {
        cb(true);
      } else {
        cb(false);
      }
    }
1024391
def _handle_401(self, data):
        """"""

        ex = ConnectionError(
            "Can't login to a protected room without a proper password", data
        )
        self.conn.reraise(ex)
1061838
function(next) {
      // already connected to service? stop
      if (targetServiceProperties.state === STATES.READY ||
          targetServiceProperties.state === STATES.ONLINE) {
        debug('already connected');
        if (callback) callback();
        _lockJoin = false;
        return;
      } else {
        next();
      }
    }
1153667
def is_active(self, instance, conditions):
        
        if isinstance(instance, User):
            return super(UserConditionSet, self).is_active(instance, conditions)

        # HACK: allow is_authenticated to work on AnonymousUser
        condition = conditions.get(self.get_namespace(), {}).get('is_anonymous')
        if condition is not None:
            return bool(condition)
        return None
275862
public static function check() {
		if (R::count("permission") < 1) {
			$role       = R::dispense("permission");
			$role->name = "guest";
			R::store($role);
		}
	}
855188
def check_entry(self, entries, *args, **kwargs):
        
        verbosity = kwargs.get('verbosity', 1)
        user_total_overlaps = 0
        user = ''
        for index_a, entry_a in enumerate(entries):
            # Show the name the first time through
            if index_a == 0:
                if args and verbosity >= 1 or verbosity >= 2:
                    self.show_name(entry_a.user)
                    user = entry_a.user
            for index_b in range(index_a, len(entries)):
                entry_b = entries[index_b]
                if entry_a.check_overlap(entry_b):
                    user_total_overlaps += 1
                    self.show_overlap(entry_a, entry_b, verbosity=verbosity)
        if user_total_overlaps and user and verbosity >= 1:
            overlap_data = {
                'first': user.first_name,
                'last': user.last_name,
                'total': user_total_overlaps,
            }
            self.stdout.write('Total overlapping entries for user ' +
                              '%(first)s %(last)s: %(total)d' % overlap_data)
        return user_total_overlaps
345221
def isInRoom(self, _id):
        
        if SockJSRoomHandler._room.has_key(self._gcls() + _id):
            if self in SockJSRoomHandler._room[self._gcls() + _id]:
                return True
        return False
959385
def members(options = {})
      response = self.class.get(@api.member_config[:url],
        :query => { :auth_token => @token }.merge(options),
        :headers => @api.headers)

      ErrorHandler.response_code_to_exception_for :room, room_id, response
      wrap_users(response)
    end
130814
def check_entry(*entry):
    """"""
    whitelist = read_whitelist()
    if not check_allow_prompt(entry, whitelist):
        whitelist.append(entry)
        write_whitelist(whitelist)
143962
def check_user(self, todays_facts):
        """"""
        interval = self.conf_notify_interval
        if interval <= 0 or interval >= 121:
            return

        now = dt.datetime.now()
        message = None

        last_activity = todays_facts[-1] if todays_facts else None

        # update duration of current task
        if last_activity and not last_activity['end_time']:
            delta = now - last_activity['start_time']
            duration = delta.seconds /  60

            if duration and duration % interval == 0:
                message = _("Working on %s") % last_activity['name']
                self.notify_user(message)

        elif self.conf_notify_on_idle:
            #if we have no last activity, let's just calculate duration from 00:00
            if (now.minute + now.hour * 60) % interval == 0:
                self.notify_user(_("No activity"))
87744
def kick_user(self, room_id, user_id, reason=""):
        
        self.set_membership(room_id, user_id, "leave", reason)
1083949
private void pingMemberIfRequired(long now, Member member) {
        if (!icmpEnabled || icmpParallelMode) {
            return;
        }

        long lastHeartbeat = heartbeatFailureDetector.lastHeartbeat(member);
        if ((now - lastHeartbeat) >= legacyIcmpCheckThresholdMillis) {
            runPingTask(member);
        }
    }
1093957
def subscriptions_unread(self, room_id, **kwargs):
        """"""
        return self.__call_api_post('subscriptions.unread', roomId=room_id, kwargs=kwargs)
816681
public static boolean checkForServiceAccount(String userLdapDN, ApiSettings settings,Map<String,String> allowedUsers,String author,List<String> commitFiles,boolean isCommit,AuditReviewResponse auditReviewResponse) {
        List<String> serviceAccountOU = settings.getServiceAccountOU();
        boolean isValid = false;
        if(!MapUtils.isEmpty(allowedUsers) && isCommit){
            isValid = isValidServiceAccount(author,allowedUsers,commitFiles);
            if(isValid){
                auditReviewResponse.addAuditStatus(CodeReviewAuditStatus.DIRECT_COMMIT_CHANGE_WHITELISTED_ACCOUNT);
            }
        }
        if (!CollectionUtils.isEmpty(serviceAccountOU) && StringUtils.isNotBlank(userLdapDN) && !isValid) {
            try {
                String userLdapDNParsed = LdapUtils.getStringValue(new LdapName(userLdapDN), "OU");
                List<String> matches = serviceAccountOU.stream().filter(it -> it.contains(userLdapDNParsed)).collect(Collectors.toList());
                isValid =  CollectionUtils.isNotEmpty(matches);
            } catch (InvalidNameException e) {
                LOGGER.error("Error parsing LDAP DN:" + userLdapDN);
            }
        }
        else {
            LOGGER.info("API Settings missing service account RDN");
        }
        return isValid;
    }