Logo Search packages:      
Sourcecode: ubuntuone-client version File versions

states.py

# ubuntuone.syncdaemon.states - SyncDaemon states
#
# Author: John Lenton <john.lenton@canonical.com>
#
# Copyright 2009 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
The states of the SyncDaemon
"""

00022 class BadTransition(Exception):
    """
    An event arrived that the state didn't know how to handle.
    """

00027 class UndefinedState(Exception):
    """
    The target state doesn't exist.
    """

00032 class SyncDaemonState(object):
    """
    A SyncDaemon state.
    """
    def __repr__(self):
        return '<%s %s>' % (self.__class__.__name__,
                            self.name)

    def __init__(self, name, description,
                 sys_net_connected_trn, sys_connect_trn,
                 sys_net_disconnected_trn, sys_disconnect_trn,
                 sys_connection_lost_trn,
                 is_error=False, is_connected=False, is_online=False,
                 enter=None,
                 **other_transitions):
        self.name = name
        self.description = description
        self.is_error = is_error
        self.is_connected = is_connected
        self.is_online = is_online
        self.enter = enter
        self.transitions = dict(SYS_NET_CONNECTED=sys_net_connected_trn,
                                SYS_CONNECT=sys_connect_trn,
                                SYS_NET_DISCONNECTED=sys_net_disconnected_trn,
                                SYS_DISCONNECT=sys_disconnect_trn,
                                SYS_CONNECTION_LOST=sys_connection_lost_trn,
                                **other_transitions)

00060     def next(self, event):
        """
        Determine the next state, given the current state and the event.
        That makes us a Moore FSM, right?
        """
        if event in self.transitions:
            new = self.transitions[event]
            if new in globals():
                return globals()[new]
            else:
                raise UndefinedState("State %s is undefined" % new)
        else:
            raise BadTransition("State %s can't handle the %s event"
                                % (self.name, event))

00075 class NonActiveConnectedSDState(SyncDaemonState):
    """
    States that handle network disconnections with no cleanup
    required.
    """
    def __init__(self, name, description, is_online=False, with_q=None,
                 **other_transitions):
        ready_waiting = 'READY_WAITING'
        ready_w_network = 'READY_WITH_NETWORK'
        start_connecting = 'START_CONNECTING'
        if with_q is not None:
            ready_waiting += '_WITH_' + with_q
            ready_w_network += '_WITH_' + with_q
            start_connecting += '_WITH_' + with_q
        if name.startswith('START_'):
            same = name[6:]
        else:
            same = name
        super(NonActiveConnectedSDState, self).__init__(name, description,
                                                        same, same,
                                                        ready_waiting,
                                                        ready_w_network,
                                                        start_connecting,
                                                        is_connected=True,
                                                        is_online=is_online,
                                                        **other_transitions)

00102 class WorkingSDState(SyncDaemonState):
    """
    States that handle network disconnections by doing cleanup.
    """
    def __init__(self, name, description, **other_transitions):
        super(WorkingSDState, self).__init__(
            name, description, name, name,
            'START_CLEANUP_WAITING',
            'START_CONNECTED_CLEANUP',
            'START_CLEANUP_WAITING_WITH_NETWORK',
            is_connected=True, is_online=True,
            **other_transitions)

00115 class AQErrorState(SyncDaemonState):
    """
    States that are errors.
    """
    def __init__(self, name, description):
        super(AQErrorState, self).__init__(name, description,
                                           name, name, name, name, name,
                                           is_error=True)

00124     def next(self, event):
        """
        The next state of an error is always itself.
        """
        return self


INIT = SyncDaemonState(
    'INIT', 'just initialized',
    'INIT_WITH_NETWORK', 'INIT_WAITING',
    'INIT', 'INIT', 'INIT',
    SYS_WAIT_FOR_LOCAL_RESCAN='READING',
    )

INIT_WITH_NETWORK = SyncDaemonState(
    'INIT_WITH_NETWORK',
    'just initialized, but already has network',
    'INIT_WITH_NETWORK', 'INIT_WAITING_WITH_NETWORK',
    'INIT', 'INIT_WITH_NETWORK', 'INIT_WITH_NETWORK',
    SYS_WAIT_FOR_LOCAL_RESCAN='READING_WITH_NETWORK',
    )

INIT_WAITING = SyncDaemonState(
    'INIT_WAITING',
    'just initialized, but the user already wants to connect',
    'INIT_WAITING_WITH_NETWORK', 'INIT_WAITING',
    'INIT_WAITING', 'INIT', 'INIT_WAITING',
    SYS_WAIT_FOR_LOCAL_RESCAN='READING_WAITING',
    )

INIT_WAITING_WITH_NETWORK = SyncDaemonState(
    'INIT_WAITING_WITH_NETWORK',
    'just initialized, user wants to connect, and network is available',
    'INIT_WAITING_WITH_NETWORK', 'INIT_WAITING_WITH_NETWORK',
    'INIT_WAITING', 'INIT_WITH_NETWORK', 'INIT_WAITING_WITH_NETWORK',
    SYS_WAIT_FOR_LOCAL_RESCAN='READING_WAITING_WITH_NETWORK',
    )

READING = SyncDaemonState(
    'READING',
    'doing local rescan',
    'READING_WITH_NETWORK', 'READING_WAITING',
    'READING', 'READING', 'READING',
    SYS_LOCAL_RESCAN_DONE='READY_FOR_NETWORK',
    SYS_META_QUEUE_WAITING='READING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_CONTQ',
    )

READING_WITH_METAQ = SyncDaemonState(
    'READING_WITH_METAQ',
    'doing local rescan, meta_q waiting',
    'READING_WITH_NETWORK_WITH_METAQ', 'READING_WAITING_WITH_METAQ',
    'READING_WITH_METAQ', 'READING_WITH_METAQ', 'READING_WITH_METAQ',
    SYS_LOCAL_RESCAN_DONE='READY_FOR_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_BOTHQ',
    )

READING_WITH_CONTQ = SyncDaemonState(
    'READING_WITH_CONTQ',
    'doing local rescan, content_q waiting',
    'READING_WITH_NETWORK_WITH_CONTQ', 'READING_WAITING_WITH_CONTQ',
    'READING_WITH_CONTQ', 'READING_WITH_CONTQ', 'READING_WITH_CONTQ',
    SYS_LOCAL_RESCAN_DONE='READY_FOR_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_CONTQ',
    )

READING_WITH_BOTHQ = SyncDaemonState(
    'READING_WITH_BOTHQ',
    'doing local rescan, both _q\'s waiting',
    'READING_WITH_NETWORK_WITH_BOTHQ', 'READING_WAITING_WITH_BOTHQ',
    'READING_WITH_BOTHQ', 'READING_WITH_BOTHQ', 'READING_WITH_BOTHQ',
    SYS_LOCAL_RESCAN_DONE='READY_FOR_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_BOTHQ',
    )

READING_WITH_NETWORK = SyncDaemonState(
    'READING_WITH_NETWORK',
    'doing local rescan; network is available',
    'READING_WITH_NETWORK', 'READING_WAITING_WITH_NETWORK',
    'READING', 'READING_WITH_NETWORK', 'READING_WITH_NETWORK',
    SYS_LOCAL_RESCAN_DONE='READY_WITH_NETWORK',
    SYS_META_QUEUE_WAITING='READING_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_NETWORK_WITH_CONTQ',
    )

READING_WITH_NETWORK_WITH_METAQ = SyncDaemonState(
    'READING_WITH_NETWORK_WITH_METAQ',
    'doing local rescan; network is available, meta_q waiting',
    'READING_WITH_NETWORK_WITH_METAQ',
    'READING_WAITING_WITH_NETWORK_WITH_METAQ',
    'READING_WITH_METAQ', 'READING_WITH_NETWORK_WITH_METAQ',
    'READING_WITH_NETWORK_WITH_METAQ',
    SYS_LOCAL_RESCAN_DONE='READY_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_NETWORK_WITH_BOTHQ',
    )

READING_WITH_NETWORK_WITH_CONTQ = SyncDaemonState(
    'READING_WITH_NETWORK_WITH_CONTQ',
    'doing local rescan; network is available, content_q waiting',
    'READING_WITH_NETWORK_WITH_CONTQ',
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    'READING_WITH_CONTQ', 'READING_WITH_NETWORK_WITH_CONTQ',
    'READING_WITH_NETWORK_WITH_CONTQ',
    SYS_LOCAL_RESCAN_DONE='READY_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READING_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_NETWORK_WITH_CONTQ',
    )

READING_WITH_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'READING_WITH_NETWORK_WITH_BOTHQ',
    'doing local rescan; network is available, both _q\'s waiting',
    'READING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WITH_BOTHQ', 'READING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WITH_NETWORK_WITH_BOTHQ',
    SYS_LOCAL_RESCAN_DONE='READY_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WITH_NETWORK_WITH_BOTHQ',
    )

READING_WAITING = SyncDaemonState(
    'READING_WAITING',
    'doing local rescan; user wants to connect',
    'READING_WAITING_WITH_NETWORK', 'READING_WAITING',
    'READING_WAITING', 'READING', 'READING_WAITING',
    SYS_LOCAL_RESCAN_DONE='READY_WAITING',
    SYS_META_QUEUE_WAITING='READING_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_CONTQ',
    )

READING_WAITING_WITH_METAQ = SyncDaemonState(
    'READING_WAITING_WITH_METAQ',
    'doing local rescan; user wants to connect, meta_q waiting',
    'READING_WAITING_WITH_NETWORK_WITH_METAQ', 'READING_WAITING_WITH_METAQ',
    'READING_WAITING_WITH_METAQ', 'READING_WITH_METAQ',
    'READING_WAITING_WITH_METAQ',
    SYS_LOCAL_RESCAN_DONE='READY_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_BOTHQ',
    )

READING_WAITING_WITH_CONTQ = SyncDaemonState(
    'READING_WAITING_WITH_CONTQ',
    'doing local rescan; user wants to connect, content_q waiting',
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ', 'READING_WAITING_WITH_CONTQ',
    'READING_WAITING_WITH_CONTQ', 'READING_WITH_CONTQ',
    'READING_WAITING_WITH_CONTQ',
    SYS_LOCAL_RESCAN_DONE='READY_WAITING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READING_WAITING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_CONTQ',
    )

READING_WAITING_WITH_BOTHQ = SyncDaemonState(
    'READING_WAITING_WITH_BOTHQ',
    'doing local rescan; user wants to connect, both _q\'s waiting',
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ', 'READING_WAITING_WITH_BOTHQ',
    'READING_WAITING_WITH_BOTHQ', 'READING_WITH_BOTHQ',
    'READING_WAITING_WITH_BOTHQ',
    SYS_LOCAL_RESCAN_DONE='READY_WAITING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_BOTHQ',
    )

READING_WAITING_WITH_NETWORK = SyncDaemonState(
    'READING_WAITING_WITH_NETWORK',
    'doing local rescan; user wants to connect, and network is available',
    'READING_WAITING_WITH_NETWORK', 'READING_WAITING_WITH_NETWORK',
    'READING_WAITING', 'READING_WITH_NETWORK',
    'READING_WAITING_WITH_NETWORK',
    SYS_LOCAL_RESCAN_DONE='START_CONNECTING',
    SYS_META_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    )

READING_WAITING_WITH_NETWORK_WITH_METAQ = SyncDaemonState(
    'READING_WAITING_WITH_NETWORK_WITH_METAQ',
    'doing local rescan; user wants to connect, network is available,'
        ' meta_q waiting',
    'READING_WAITING_WITH_NETWORK_WITH_METAQ',
    'READING_WAITING_WITH_NETWORK_WITH_METAQ',
    'READING_WAITING_WITH_METAQ', 'READING_WITH_NETWORK_WITH_METAQ',
    'READING_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_LOCAL_RESCAN_DONE='START_CONNECTING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    )

READING_WAITING_WITH_NETWORK_WITH_CONTQ = SyncDaemonState(
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    'doing local rescan; user wants to connect, network is available,'
        ' content_q waiting',
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    'READING_WAITING_WITH_CONTQ', 'READING_WITH_NETWORK_WITH_CONTQ',
    'READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_LOCAL_RESCAN_DONE='START_CONNECTING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_CONTQ',
    )

READING_WAITING_WITH_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'doing local rescan; user wants to connect, network is available,'
        ' both _q\'s waiting',
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WAITING_WITH_BOTHQ', 'READING_WITH_NETWORK_WITH_BOTHQ',
    'READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_LOCAL_RESCAN_DONE='START_CONNECTING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READING_WAITING_WITH_NETWORK_WITH_BOTHQ',
    )

READY_FOR_NETWORK = SyncDaemonState(
    'READY_FOR_NETWORK',
    'ready to connect as soon as the user says so and the network comes up.',
    'READY_WITH_NETWORK', 'READY_WAITING',
    'READY_FOR_NETWORK', 'READY_FOR_NETWORK', 'READY_FOR_NETWORK',
    SYS_META_QUEUE_WAITING='READY_FOR_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_FOR_NETWORK_WITH_CONTQ',
    )

READY_FOR_NETWORK_WITH_METAQ = SyncDaemonState(
    'READY_FOR_NETWORK_WITH_METAQ',
    'ready to connect as soon as the user says so and the network comes up.'
    + ' Meta queue is waiting.',
    'READY_WITH_NETWORK_WITH_METAQ', 'READY_WAITING_WITH_METAQ',
    'READY_FOR_NETWORK_WITH_METAQ', 'READY_FOR_NETWORK_WITH_METAQ',
    'READY_FOR_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_FOR_NETWORK_WITH_BOTHQ',
    )

READY_FOR_NETWORK_WITH_CONTQ = SyncDaemonState(
    'READY_FOR_NETWORK_WITH_CONTQ',
    'ready to connect as soon as the user says so and the network comes up.'
    + ' Content queue is waiting.',
    'READY_WITH_NETWORK_WITH_CONTQ', 'READY_WAITING_WITH_CONTQ',
    'READY_FOR_NETWORK_WITH_CONTQ', 'READY_FOR_NETWORK_WITH_CONTQ',
    'READY_FOR_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READY_FOR_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READY_FOR_NETWORK_WITH_CONTQ',
    )

READY_FOR_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'READY_FOR_NETWORK_WITH_BOTHQ',
    'ready to connect as soon as the user says so and the network comes up.'
    + ' Both request queues are waiting.',
    'READY_WITH_NETWORK_WITH_BOTHQ', 'READY_WAITING_WITH_BOTHQ',
    'READY_FOR_NETWORK_WITH_BOTHQ', 'READY_FOR_NETWORK_WITH_BOTHQ',
    'READY_FOR_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READY_FOR_NETWORK_WITH_BOTHQ',
    )

READY_WITH_NETWORK = SyncDaemonState(
    'READY_WITH_NETWORK',
    'ready to connect, network is up, user is yet to push "go"',
    'READY_WITH_NETWORK', 'START_CONNECTING',
    'READY_FOR_NETWORK', 'READY_WITH_NETWORK', 'READY_WITH_NETWORK',
    SYS_META_QUEUE_WAITING='READY_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WITH_NETWORK_WITH_CONTQ',
    )

READY_WITH_NETWORK_WITH_METAQ = SyncDaemonState(
    'READY_WITH_NETWORK_WITH_METAQ',
    'ready to connect, network up, meta_q waiting, user yet to push "go"',
    'READY_WITH_NETWORK_WITH_METAQ', 'START_CONNECTING_WITH_METAQ',
    'READY_FOR_NETWORK_WITH_METAQ', 'READY_WITH_NETWORK_WITH_METAQ',
    'READY_WITH_NETWORK_WITH_METAQ',
    SYS_META_QUEUE_WAITING='READY_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WITH_NETWORK_WITH_BOTHQ',
    )

READY_WITH_NETWORK_WITH_CONTQ = SyncDaemonState(
    'READY_WITH_NETWORK_WITH_CONTQ',
    'ready to connect, network up, content_q waiting, user yet to push "go"',
    'READY_WITH_NETWORK_WITH_CONTQ', 'START_CONNECTING_WITH_CONTQ',
    'READY_FOR_NETWORK_WITH_CONTQ', 'READY_WITH_NETWORK_WITH_CONTQ',
    'READY_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READY_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WITH_NETWORK_WITH_CONTQ',
    )

READY_WITH_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'READY_WITH_NETWORK_WITH_BOTHQ',
    'ready to connect, network up, both _q\'s waiting, user yet to push "go"',
    'READY_WITH_NETWORK_WITH_BOTHQ', 'START_CONNECTING_WITH_BOTHQ',
    'READY_FOR_NETWORK_WITH_BOTHQ', 'READY_WITH_NETWORK_WITH_BOTHQ',
    'READY_WITH_NETWORK_WITH_BOTHQ',
    SYS_META_QUEUE_WAITING='READY_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WITH_NETWORK_WITH_BOTHQ',
    )

READY_WAITING = SyncDaemonState(
    'READY_WAITING',
    'ready to connect; user said "go", network is down',
    'START_CONNECTING', 'READY_WAITING',
    'READY_WAITING', 'READY_FOR_NETWORK', 'READY_WAITING',
    SYS_META_QUEUE_WAITING='READY_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WAITING_WITH_CONTQ',
)

READY_WAITING_WITH_METAQ = SyncDaemonState(
    'READY_WAITING_WITH_METAQ',
    'ready to connect; user said "go", network is down, meta_q waiting',
    'START_CONNECTING_WITH_METAQ', 'READY_WAITING_WITH_METAQ',
    'READY_WAITING_WITH_METAQ', 'READY_FOR_NETWORK_WITH_METAQ',
    'READY_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WAITING_WITH_BOTHQ',
)

READY_WAITING_WITH_CONTQ = SyncDaemonState(
    'READY_WAITING_WITH_CONTQ',
    'ready to connect; user said "go", network is down, content_q waiting',
    'START_CONNECTING_WITH_CONTQ', 'READY_WAITING_WITH_CONTQ',
    'READY_WAITING_WITH_CONTQ', 'READY_FOR_NETWORK_WITH_CONTQ',
    'READY_WAITING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='READY_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WAITING_WITH_CONTQ',
)

READY_WAITING_WITH_BOTHQ = SyncDaemonState(
    'READY_WAITING_WITH_BOTHQ',
    'ready to connect; user said "go", network is down, both _q\'s waiting',
    'START_CONNECTING_WITH_BOTHQ', 'READY_WAITING_WITH_BOTHQ',
    'READY_WAITING_WITH_BOTHQ', 'READY_FOR_NETWORK_WITH_BOTHQ',
    'READY_WAITING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='READY_WAITING_WITH_BOTHQ',
)

START_CONNECTING = SyncDaemonState(
    'START_CONNECTING',
    'started waiting for the socket to come up',
    'CONNECTING', 'CONNECTING',
    'READY_WAITING', 'READY_WITH_NETWORK', 'START_CONNECTING',
    SYS_CONNECTION_MADE='START_CONNECTED',
    SYS_META_QUEUE_WAITING='CONNECTING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_CONTQ',
    enter=lambda m: m.action_q.connect(),
    )

START_CONNECTING_WITH_METAQ = SyncDaemonState(
    'START_CONNECTING_WITH_METAQ',
    'started waiting for the socket to come up; meta_q waiting',
    'CONNECTING_WITH_METAQ', 'CONNECTING_WITH_METAQ',
    'READY_WAITING_WITH_METAQ', 'READY_WITH_NETWORK_WITH_METAQ',
    'START_CONNECTING_WITH_METAQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    enter=lambda m: m.action_q.connect(),
    )

START_CONNECTING_WITH_CONTQ = SyncDaemonState(
    'START_CONNECTING_WITH_CONTQ',
    'started waiting for the socket to come up; content_q waiting',
    'CONNECTING_WITH_CONTQ', 'CONNECTING_WITH_CONTQ',
    'READY_WAITING_WITH_CONTQ', 'READY_WITH_NETWORK_WITH_CONTQ',
    'START_CONNECTING_WITH_CONTQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_CONTQ',
    enter=lambda m: m.action_q.connect(),
    )

START_CONNECTING_WITH_BOTHQ = SyncDaemonState(
    'START_CONNECTING_WITH_BOTHQ',
    'started waiting for the socket to come up; both _q\'s waiting',
    'CONNECTING_WITH_BOTHQ', 'CONNECTING_WITH_BOTHQ',
    'READY_WAITING_WITH_BOTHQ', 'READY_WITH_NETWORK_WITH_BOTHQ',
    'START_CONNECTING_WITH_BOTHQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    enter=lambda m: m.action_q.connect(),
    )

CONNECTING = SyncDaemonState(
    'CONNECTING',
    'waiting for the socket to come up',
    'CONNECTING', 'CONNECTING',
    'READY_WAITING', 'READY_WITH_NETWORK', 'START_CONNECTING',
    SYS_CONNECTION_MADE='START_CONNECTED',
    SYS_META_QUEUE_WAITING='CONNECTING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_CONTQ',
    )

CONNECTING_WITH_METAQ = SyncDaemonState(
    'CONNECTING_WITH_METAQ',
    'waiting for the socket to come up; meta_q waiting',
    'CONNECTING_WITH_METAQ', 'CONNECTING_WITH_METAQ',
    'READY_WAITING_WITH_METAQ', 'READY_WITH_NETWORK_WITH_METAQ',
    'START_CONNECTING_WITH_METAQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    )

CONNECTING_WITH_CONTQ = SyncDaemonState(
    'CONNECTING_WITH_CONTQ',
    'waiting for the socket to come up; content_q waiting',
    'CONNECTING_WITH_CONTQ', 'CONNECTING_WITH_CONTQ',
    'READY_WAITING_WITH_CONTQ', 'READY_WITH_NETWORK_WITH_CONTQ',
    'START_CONNECTING_WITH_CONTQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_CONTQ',
    )

CONNECTING_WITH_BOTHQ = SyncDaemonState(
    'CONNECTING_WITH_BOTHQ',
    'waiting for the socket to come up; both _q\'s waiting',
    'CONNECTING_WITH_BOTHQ', 'CONNECTING_WITH_BOTHQ',
    'READY_WAITING_WITH_BOTHQ', 'READY_WITH_NETWORK_WITH_BOTHQ',
    'START_CONNECTING_WITH_BOTHQ',
    SYS_CONNECTION_MADE='START_CONNECTED_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTING_WITH_BOTHQ',
    )

START_CONNECTED = NonActiveConnectedSDState(
    'START_CONNECTED',
    'socket came up! start checking protocol version',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING',
    SYS_META_QUEUE_WAITING='CONNECTED_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_CONTQ',
    enter=lambda m: m.check_version(),
    )

START_CONNECTED_WITH_METAQ = NonActiveConnectedSDState(
    'START_CONNECTED_WITH_METAQ',
    'socket came up! start checking protocol version; meta_q waiting',
    with_q='METAQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    enter=lambda m: m.check_version(),
    )

START_CONNECTED_WITH_CONTQ = NonActiveConnectedSDState(
    'START_CONNECTED_WITH_CONTQ',
    'socket came up! start checking protocol version; content_q waiting',
    with_q='CONTQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_CONTQ',
    enter=lambda m: m.check_version(),
    )

START_CONNECTED_WITH_BOTHQ = NonActiveConnectedSDState(
    'START_CONNECTED_WITH_BOTHQ',
    'socket came up! start checking protocol version both _q\'s waiting',
    with_q='BOTHQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    enter=lambda m: m.check_version(),
    )

CONNECTED = NonActiveConnectedSDState(
    'CONNECTED',
    'socket came up! checking protocol version',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING',
    SYS_META_QUEUE_WAITING='CONNECTED_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_CONTQ',
    )

CONNECTED_WITH_METAQ = NonActiveConnectedSDState(
    'CONNECTED_WITH_METAQ',
    'socket came up! checking protocol version; meta_q waiting',
    with_q='METAQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    )

CONNECTED_WITH_CONTQ = NonActiveConnectedSDState(
    'CONNECTED_WITH_CONTQ',
    'socket came up! checking protocol version; content_q waiting',
    with_q='CONTQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_CONTQ',
    )

CONNECTED_WITH_BOTHQ = NonActiveConnectedSDState(
    'CONNECTED_WITH_BOTHQ',
    'socket came up! checking protocol version both _q\'s waiting',
    with_q='BOTHQ',
    SYS_PROTOCOL_VERSION_ERROR='BAD_VERSION',
    SYS_PROTOCOL_VERSION_OK='START_AUTHENTICATING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CONNECTED_WITH_BOTHQ',
    )

BAD_VERSION = AQErrorState(
    'BAD_VERSION',
    'Protocol version mismatch. You probably need to upgrade',
    )

START_AUTHENTICATING = NonActiveConnectedSDState(
    'START_AUTHENTICATING',
    'Start doing the OAuth dance',
    SYS_OAUTH_OK='SCANNING_START',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_META_QUEUE_WAITING='AUTHENTICATING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_CONTQ',
    enter=lambda m: m.authenticate(),
    )

START_AUTHENTICATING_WITH_METAQ = NonActiveConnectedSDState(
    'START_AUTHENTICATING_WITH_METAQ',
    'Start doing the OAuth dance; meta_q waiting',
    with_q='METAQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_METAQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    enter=lambda m: m.authenticate(),
    )

START_AUTHENTICATING_WITH_CONTQ = NonActiveConnectedSDState(
    'START_AUTHENTICATING_WITH_CONTQ',
    'Start doing the OAuth dance; content_q waiting',
    with_q='CONTQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_CONTQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_META_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_CONTQ',
    enter=lambda m: m.authenticate(),
    )

START_AUTHENTICATING_WITH_BOTHQ = NonActiveConnectedSDState(
    'START_AUTHENTICATING_WITH_BOTHQ',
    'Start doing the OAuth dance; both _q\'s waiting',
    with_q='CONTQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_BOTHQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    enter=lambda m: m.authenticate(),
    )

AUTHENTICATING = NonActiveConnectedSDState(
    'AUTHENTICATING',
    'Doing the OAuth dance',
    SYS_OAUTH_OK='SCANNING_START',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_META_QUEUE_WAITING='AUTHENTICATING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_CONTQ',
    )

AUTHENTICATING_WITH_METAQ = NonActiveConnectedSDState(
    'AUTHENTICATING_WITH_METAQ',
    'Doing the OAuth dance; meta_q waiting',
    with_q='METAQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_METAQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    )

AUTHENTICATING_WITH_CONTQ = NonActiveConnectedSDState(
    'AUTHENTICATING_WITH_CONTQ',
    'Doing the OAuth dance; content_q waiting',
    with_q='CONTQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_CONTQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_META_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_CONTQ',
    )

AUTHENTICATING_WITH_BOTHQ = NonActiveConnectedSDState(
    'AUTHENTICATING_WITH_BOTHQ',
    'Doing the OAuth dance; both _q\'s waiting',
    with_q='CONTQ',
    SYS_OAUTH_OK='SCANNING_START_WITH_BOTHQ',
    SYS_OAUTH_ERROR='AUTH_FAILED',
    SYS_CONTENT_QUEUE_WAITING='AUTHENTICATING_WITH_BOTHQ',
    )

AUTH_FAILED = AQErrorState(
    'AUTH_FAILED',
    'OAuth failed')

UNKNOWN_ERROR = AQErrorState(
    'UNKNOWN_ERROR',
    "Some kind of strange error happened and I can't continue")

SCANNING_START = NonActiveConnectedSDState(
    'SCANNING_START',
    'start doing server rescan',
    SYS_SERVER_RESCAN_STARTING='SCANNING',
    SYS_META_QUEUE_WAITING='SCANNING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_CONTQ',
    enter=lambda m: m.server_rescan(),
    )

SCANNING_START_WITH_METAQ = NonActiveConnectedSDState(
    'SCANNING_START_WITH_METAQ',
    'start doing server rescan, meta queue is waiting',
    with_q='METAQ',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_METAQ',
    SYS_META_QUEUE_WAITING='SCANNING_WITH_METAQ',
    enter=lambda m: m.server_rescan(),
    )

SCANNING_START_WITH_CONTQ = NonActiveConnectedSDState(
    'SCANNING_START_WITH_CONTQ',
    'start doing server rescan, content queue waiting',
    with_q='CONTQ',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='SCANNING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_CONTQ',
    enter=lambda m: m.server_rescan(),
    )

SCANNING_START_WITH_BOTHQ = NonActiveConnectedSDState(
    'SCANNING_START_WITH_BOTHQ',
    'start doing server rescan, both request queues waiting',
    with_q='CONTQ',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_BOTHQ',
    enter=lambda m: m.server_rescan(),
    )

SCANNING = NonActiveConnectedSDState(
    'SCANNING',
    'doing server rescan',
    SYS_SERVER_RESCAN_DONE='IDLE',
    SYS_SERVER_RESCAN_STARTING='SCANNING',
    SYS_META_QUEUE_WAITING='SCANNING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_CONTQ',
    )

SCANNING_WITH_METAQ = NonActiveConnectedSDState(
    'SCANNING_WITH_METAQ',
    'doing server rescan, meta queue is waiting',
    with_q='METAQ',
    SYS_SERVER_RESCAN_DONE='START_WORKING_ON_METADATA',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_BOTHQ',
    )

SCANNING_WITH_CONTQ = NonActiveConnectedSDState(
    'SCANNING_WITH_CONTQ',
    'doing server rescan, content queue waiting',
    with_q='CONTQ',
    SYS_SERVER_RESCAN_DONE='START_WORKING_ON_CONTENT',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='SCANNING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_CONTQ',
    )

SCANNING_WITH_BOTHQ = NonActiveConnectedSDState(
    'SCANNING_WITH_BOTHQ',
    'doing server rescan, both request queues waiting',
    with_q='CONTQ',
    SYS_SERVER_RESCAN_DONE='START_WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    SYS_SERVER_RESCAN_STARTING='SCANNING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='SCANNING_WITH_BOTHQ',
    )

IDLE = NonActiveConnectedSDState(
    'IDLE',
    'nothing on the wire right now',
    is_online=True,
    SYS_META_QUEUE_WAITING='START_WORKING_ON_METADATA',
    SYS_CONTENT_QUEUE_WAITING='START_WORKING_ON_CONTENT',
    )

START_WORKING_ON_METADATA = WorkingSDState(
    'START_WORKING_ON_METADATA',
    'start working on metadata',
    SYS_META_QUEUE_WAITING='WORKING_ON_METADATA',
    SYS_META_QUEUE_DONE='IDLE',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    enter=lambda m: m.action_q.meta_queue.run(),
    )

WORKING_ON_METADATA = WorkingSDState(
    'WORKING_ON_METADATA',
    'working on metadata',
    SYS_META_QUEUE_WAITING='WORKING_ON_METADATA',
    SYS_META_QUEUE_DONE='IDLE',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    )

START_WORKING_ON_CONTENT = WorkingSDState(
    'START_WORKING_ON_CONTENT',
    'start working on content',
    SYS_META_QUEUE_WAITING='START_WORKING_ON_BOTH',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_DONE='IDLE',
    enter=lambda m: m.action_q.content_queue.run(),
    )

WORKING_ON_CONTENT = WorkingSDState(
    'WORKING_ON_CONTENT',
    'working on content',
    SYS_META_QUEUE_WAITING='START_WORKING_ON_BOTH',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_DONE='IDLE',
    )

START_WORKING_ON_METADATA_WITH_CONTENT_WAITING = WorkingSDState(
    'START_WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    'start working on metadata; content work is waiting also',
    SYS_META_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    SYS_META_QUEUE_DONE='START_WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    enter=lambda m: m.action_q.meta_queue.run(),
    )

WORKING_ON_METADATA_WITH_CONTENT_WAITING = WorkingSDState(
    'WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    'working on metadata; content work is waiting',
    SYS_META_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    SYS_META_QUEUE_DONE='START_WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_METADATA_WITH_CONTENT_WAITING',
    )

START_WORKING_ON_BOTH = WorkingSDState(
    'START_WORKING_ON_BOTH',
    'start working on both content and metadata',
    SYS_META_QUEUE_WAITING='WORKING_ON_BOTH',
    SYS_META_QUEUE_DONE='WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_BOTH',
    SYS_CONTENT_QUEUE_DONE='WORKING_ON_METADATA',
    enter=lambda m: m.action_q.meta_queue.run(),
    )

WORKING_ON_BOTH = WorkingSDState(
    'WORKING_ON_BOTH',
    'working on both content and metadata',
    SYS_META_QUEUE_WAITING='WORKING_ON_BOTH',
    SYS_META_QUEUE_DONE='WORKING_ON_CONTENT',
    SYS_CONTENT_QUEUE_WAITING='WORKING_ON_BOTH',
    SYS_CONTENT_QUEUE_DONE='WORKING_ON_METADATA',
    )

CLEANUP = SyncDaemonState(
    'CLEANUP',
    'doing cleanup (net down, user asked for shutdown)',
    'CLEANUP_WITH_NETWORK', 'CLEANUP_WAITING',
    'CLEANUP', 'CLEANUP', 'CLEANUP',
    SYS_CLEANUP_STARTED='CLEANUP',
    SYS_CLEANUP_FINISHED='READY_FOR_NETWORK',
    SYS_META_QUEUE_WAITING='CLEANUP_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP', # cancelling meta_q.head can do this
    SYS_CONTENT_QUEUE_DONE='CLEANUP', # ditto
    )

CLEANUP_WITH_METAQ = SyncDaemonState(
    'CLEANUP_WITH_METAQ',
    'doing cleanup (net down, user asked for shutdown, meta_q waiting)',
    'CLEANUP_WITH_NETWORK_WITH_METAQ', 'CLEANUP_WAITING_WITH_METAQ',
    'CLEANUP_WITH_METAQ', 'CLEANUP_WITH_METAQ', 'CLEANUP_WITH_METAQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_METAQ',
    SYS_CLEANUP_FINISHED='READY_FOR_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WITH_METAQ',
    )

CLEANUP_WITH_CONTQ = SyncDaemonState(
    'CLEANUP_WITH_CONTQ',
    'doing cleanup (net down, user asked for shutdown, content_q waiting)',
    'CLEANUP_WITH_NETWORK_WITH_CONTQ', 'CLEANUP_WAITING_WITH_CONTQ',
    'CLEANUP_WITH_CONTQ', 'CLEANUP_WITH_CONTQ', 'CLEANUP_WITH_CONTQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_CONTQ',
    SYS_CLEANUP_FINISHED='READY_FOR_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CLEANUP_WITH_BOTHQ',
    SYS_META_QUEUE_DONE='CLEANUP_WITH_CONTQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_CONTQ',
    )

CLEANUP_WITH_BOTHQ = SyncDaemonState(
    'CLEANUP_WITH_BOTHQ',
    'doing cleanup (net down, user asked for shutdown, both _q\'s waiting)',
    'CLEANUP_WITH_NETWORK_WITH_BOTHQ', 'CLEANUP_WAITING_WITH_BOTHQ',
    'CLEANUP_WITH_BOTHQ', 'CLEANUP_WITH_BOTHQ', 'CLEANUP_WITH_BOTHQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_BOTHQ',
    SYS_CLEANUP_FINISHED='READY_FOR_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_BOTHQ',
    )

START_CLEANUP_WAITING = SyncDaemonState(
    'START_CLEANUP_WAITING',
    'start doing cleanup (network dropped)',
    'CLEANUP_WAITING_WITH_NETWORK', 'CLEANUP_WAITING',
    'CLEANUP_WAITING', 'CLEANUP', 'CLEANUP_WAITING',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING',
    enter=lambda m: m.action_q.cleanup(),
    )

CLEANUP_WAITING = SyncDaemonState(
    'CLEANUP_WAITING',
    'doing cleanup (network dropped)',
    'CLEANUP_WAITING_WITH_NETWORK', 'CLEANUP_WAITING',
    'CLEANUP_WAITING', 'CLEANUP', 'CLEANUP_WAITING',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING',
    SYS_CLEANUP_FINISHED='READY_WAITING',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING',
    )

CLEANUP_WAITING_WITH_METAQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_METAQ',
    'doing cleanup (network dropped, meta_q waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ', 'CLEANUP_WAITING_WITH_METAQ',
    'CLEANUP_WAITING_WITH_METAQ', 'CLEANUP_WITH_METAQ',
    'CLEANUP_WAITING_WITH_METAQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_METAQ',
    SYS_CLEANUP_FINISHED='READY_WAITING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING_WITH_METAQ',
    )

CLEANUP_WAITING_WITH_CONTQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_CONTQ',
    'doing cleanup (network dropped, content_q waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ', 'CLEANUP_WAITING_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_CONTQ', 'CLEANUP_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_CONTQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_CONTQ',
    SYS_CLEANUP_FINISHED='READY_WAITING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_BOTHQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING_WITH_CONTQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_CONTQ',
    )

CLEANUP_WAITING_WITH_BOTHQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_BOTHQ',
    'doing cleanup (network dropped, both _q\'s waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ', 'CLEANUP_WAITING_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_BOTHQ', 'CLEANUP_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_BOTHQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_BOTHQ',
    SYS_CLEANUP_FINISHED='READY_WAITING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_BOTHQ',
    )

CLEANUP_WITH_NETWORK = SyncDaemonState(
    'CLEANUP_WITH_NETWORK',
    'doing cleanup (net hiccup; user asked for shutdown)',
    'CLEANUP_WITH_NETWORK', 'CLEANUP_WAITING_WITH_NETWORK',
    'CLEANUP', 'CLEANUP_WITH_NETWORK', 'CLEANUP_WITH_NETWORK',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_NETWORK',
    SYS_CLEANUP_FINISHED='READY_WITH_NETWORK',
    SYS_META_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WITH_NETWORK',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WITH_NETWORK',
    )

CLEANUP_WITH_NETWORK_WITH_METAQ = SyncDaemonState(
    'CLEANUP_WITH_NETWORK_WITH_METAQ',
    'doing cleanup (net hiccup; user asked for shutdown; meta_q waiting)',
    'CLEANUP_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WITH_METAQ', 'CLEANUP_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WITH_NETWORK_WITH_METAQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_NETWORK_WITH_METAQ',
    SYS_CLEANUP_FINISHED='READY_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WITH_NETWORK_WITH_METAQ',
    )

CLEANUP_WITH_NETWORK_WITH_CONTQ = SyncDaemonState(
    'CLEANUP_WITH_NETWORK_WITH_CONTQ',
    'doing cleanup (net hiccup; user asked for shutdown; content_q waiting)',
    'CLEANUP_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WITH_CONTQ', 'CLEANUP_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WITH_NETWORK_WITH_CONTQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_NETWORK_WITH_CONTQ',
    SYS_CLEANUP_FINISHED='READY_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    SYS_META_QUEUE_DONE='CLEANUP_WITH_NETWORK_WITH_CONTQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_CONTQ',
    )

CLEANUP_WITH_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    'doing cleanup (net hiccup; user asked for shutdown; both _q\'s waiting)',
    'CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WITH_BOTHQ', 'CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    SYS_CLEANUP_FINISHED='READY_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    )

CLEANUP_WAITING_WITH_NETWORK = SyncDaemonState(
    'CLEANUP_WAITING_WITH_NETWORK',
    'doing cleanup (network hiccup)',
    'CLEANUP_WAITING_WITH_NETWORK', 'CLEANUP_WAITING_WITH_NETWORK',
    'CLEANUP_WAITING', 'CLEANUP_WITH_NETWORK',
    'CLEANUP_WAITING_WITH_NETWORK',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_NETWORK',
    SYS_CLEANUP_FINISHED='START_CONNECTING',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK',
    )

START_CLEANUP_WAITING_WITH_NETWORK = SyncDaemonState(
    'CLEANUP_WAITING_WITH_NETWORK',
    'doing cleanup (network hiccup)',
    'CLEANUP_WAITING_WITH_NETWORK', 'CLEANUP_WAITING_WITH_NETWORK',
    'CLEANUP_WAITING', 'CLEANUP_WITH_NETWORK', 'CLEANUP_WAITING_WITH_NETWORK',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_NETWORK',
    SYS_CLEANUP_FINISHED='START_CONNECTING',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK',
    enter=lambda m: m.action_q.cleanup(),
    )

CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    'doing cleanup (network hiccup; meta_q waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WAITING_WITH_METAQ', 'CLEANUP_WITH_NETWORK_WITH_METAQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    SYS_CLEANUP_FINISHED='START_CONNECTING_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK_WITH_METAQ',
    )

CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    'doing cleanup (network hiccup; content_q waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_CONTQ', 'CLEANUP_WITH_NETWORK_WITH_CONTQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_CLEANUP_FINISHED='START_CONNECTING_WITH_CONTQ',
    SYS_META_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_META_QUEUE_DONE='CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_CONTQ',
    )

CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ = SyncDaemonState(
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'doing cleanup (network hiccup; both _q\'s waiting)',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_BOTHQ', 'CLEANUP_WITH_NETWORK_WITH_BOTHQ',
    'CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_CLEANUP_STARTED='CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    SYS_CLEANUP_FINISHED='START_CONNECTING_WITH_BOTHQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WAITING_WITH_NETWORK_WITH_BOTHQ',
    )



# XXX CONNECTED_CLEANUP should use the network to do a "better" cleanup
START_CONNECTED_CLEANUP = SyncDaemonState(
    'START_CONNECTED_CLEANUP',
    'start doing cleanup using the network'
        ' (not yet implemented; actually starts a plain cleanup)',
    'CLEANUP_WITH_NETWORK', 'CLEANUP_WAITING_WITH_NETWORK',
    'CLEANUP', 'CLEANUP_WITH_NETWORK', 'CLEANUP_WITH_NETWORK',
    SYS_CLEANUP_STARTED='CLEANUP_WITH_NETWORK',
    SYS_CLEANUP_FINISHED='READY_WITH_NETWORK',
    SYS_META_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_METAQ',
    SYS_CONTENT_QUEUE_WAITING='CLEANUP_WITH_NETWORK_WITH_CONTQ',
    SYS_META_QUEUE_DONE='CLEANUP_WITH_NETWORK',
    SYS_CONTENT_QUEUE_DONE='CLEANUP_WITH_NETWORK',
    enter=lambda m: m.action_q.cleanup(),
    )

Generated by  Doxygen 1.6.0   Back to index