Beispiel #1
0
def rate_all_users():
    from p2p import online_status
    from p2p import p2p_connector
    if not p2p_connector.A():
        lg.warn('ratings update skipped, p2p_connector() is not running')
        return
    if p2p_connector.A().state != 'CONNECTED':
        lg.warn('ratings update skipped, p2p_connector() is CONNECTED')
        return
    if _Debug:
        lg.out(_DebugLevel, 'ratings.rate_all_users')
    monthStr = time.strftime('%B')
    for idurl in contactsdb.contacts_remote(include_all=True):
        if not idurl:
            continue
        isalive = online_status.isOnline(idurl)
        mall, malive, tall, talive = increase_rating(idurl, isalive)
        month_percent = 100.0 * float(malive) / float(mall)
        total_percent = 100.0 * float(talive) / float(tall)
        if _Debug:
            lg.out(
                _DebugLevel,
                '[%6.2f%%: %s/%s] in %s and [%6.2f%%: %s/%s] total - %s' % (
                    month_percent,
                    malive,
                    mall,
                    monthStr,
                    total_percent,
                    talive,
                    tall,
                    nameurl.GetName(idurl),
                ))
    read_index()
Beispiel #2
0
 def _on_my_identity_rotated(self, evt):
     from logs import lg
     from p2p import propagate
     from contacts import contactsdb
     known_remote_contacts = set(
         contactsdb.contacts_remote(include_all=True))
     propagate.startup_list().update(known_remote_contacts)
     lg.warn(
         'added %d known contacts to propagate startup list to be sent later'
         % len(known_remote_contacts))
Beispiel #3
0
def start(AckHandler=None, wide=False, refresh_cache=False):
    """
    Call ``propagate()`` for all known contacts.
    """
    if _Debug:
        lg.out(_DebugLevel, 'propagate.start wide=%r refresh_cache=%r' % (wide, refresh_cache))
    return propagate(
        selected_contacts=contactsdb.contacts_remote(),
        AckHandler=AckHandler,
        wide=wide,
        refresh_cache=refresh_cache,
    )
Beispiel #4
0
def start(AckHandler=None,
          wide=False,
          refresh_cache=False,
          include_all=True,
          include_enabled=True):
    """
    Call ``propagate()`` for all known contacts or only for those which are related to enabled/active services.
    """
    if _Debug:
        lg.out(
            _DebugLevel,
            'propagate.start wide=%r refresh_cache=%r' % (wide, refresh_cache))
    return propagate(
        selected_contacts=contactsdb.contacts_remote(
            include_all=include_all, include_enabled=include_enabled),
        AckHandler=AckHandler,
        wide=wide,
        refresh_cache=refresh_cache,
    )
Beispiel #5
0
def start(ack_handler=None, wide=False, refresh_cache=False, include_all=True, include_enabled=True, include_startup=False, wait_packets=False, response_timeout=10):
    """
    Call ``propagate()`` for all known contacts or only for those which are related to enabled/active services.
    """
    selected_contacts = set(filter(None, contactsdb.contacts_remote(include_all=include_all, include_enabled=include_enabled)))
    if include_startup and startup_list():
        lg.warn('going to propagate my identity also to %d nodes from startup list' % len(startup_list()))
        selected_contacts.update(startup_list())
        startup_list().clear()
    if _Debug:
        lg.args(_DebugLevel, wide=wide, refresh_cache=refresh_cache, all=include_all, enabled=include_enabled, selected=len(selected_contacts))
    return propagate(
        selected_contacts=list(selected_contacts),
        ack_handler=ack_handler,
        wide=wide,
        refresh_cache=refresh_cache,
        wait_packets=wait_packets,
        response_timeout=response_timeout,
    )
Beispiel #6
0
def rate_all_users():
    lg.out(4, 'ratings.rate_all_users')
    monthStr = time.strftime('%B')
    from p2p import online_status
    for idurl in contactsdb.contacts_remote(include_all=True):
        isalive = online_status.isOnline(idurl)
        mall, malive, tall, talive = increase_rating(idurl, isalive)
        month_percent = 100.0 * float(malive) / float(mall)
        total_percent = 100.0 * float(talive) / float(tall)
        lg.out(
            4, '[%6.2f%%: %s/%s] in %s and [%6.2f%%: %s/%s] total - %s' % (
                month_percent,
                malive,
                mall,
                monthStr,
                total_percent,
                talive,
                tall,
                nameurl.GetName(idurl),
            ))
    read_index()
Beispiel #7
0
 def isAnyPeersKnown(self, *args, **kwargs):
     """
     Condition method.
     """
     return len(contactsdb.contacts_remote()) > 0
Beispiel #8
0
def start(AckHandler=None, wide=False):
    """
    Call ``propagate()`` for all known contacts.
    """
    lg.out(6, 'propagate.start')
    return propagate(contactsdb.contacts_remote(), AckHandler, wide)