Ejemplo n.º 1
0
def stream_id_split(id):
    try:
        (account_id, feed) = (id.split('::', 1) + [None,])[:2]
    except (TypeError, ValueError):
        return (None, None)

    for account in accounts():
        if account.uuid == account_id:
            break
    else:
        return (None, None)

    return (account, feed)
Ejemplo n.º 2
0
def stream_id_split(id):
    try:
        (account_id, feed) = (id.split("::", 1) + [None])[:2]
    except (TypeError, ValueError):
        return (None, None)

    for account in accounts():
        if account.uuid == account_id:
            break
    else:
        return (None, None)

    return (account, feed)
Ejemplo n.º 3
0
    def synchronize_config(self):
        # Called to synchronize Woodchuck's configuration with our
        # configuration.
    
        # The list of known streams.
        streams = self.streams_list()
        stream_ids = [s.identifier for s in streams]
    
        freshness = refresh_interval()
    
        # Register any unknown streams.  Remove known streams from
        # STREAMS_IDS.
        def check(stream_id, name, freshness):
            if stream_id not in stream_ids:
                logging.debug(
                    "Registering previously unknown feed: %s (%s)"
                    % (name, stream_id))
                self.stream_register(stream_identifier=stream_id,
                                     human_readable_name=name,
                                     freshness=freshness)
            else:
                logging.debug(
                    "%s (%s) already registered"
                    % (name, stream_id))

                # The account name can change: it's the user's stream
                # name.
                stream_ids.remove(stream_id)
                self[stream_id].human_readable_name = name
                self[stream_id].freshness = freshness
    
        for account in accounts():
            for feed in account.feeds():
                check(stream_id_build(account, feed),
                      account.name + ': ' + feed,
                      freshness=freshness)
            yield

        # The outbox.
        check('topost', 'outbox', woodchuck.never_updated)
    
        # Unregister any streams that are no longer subscribed to.
        for stream_id in stream_ids:
            logging.debug("%s no longer registered." % (stream_id,))
            self.stream_unregister(self[stream_id])
            yield