コード例 #1
0
    def make_state_machine(self):
        if not self.connection is None:
            self.connection.close()

        callbacks = UICallbacks(FakeUI())
        callbacks.verbosity = 5
        # Knows about reading and writing bytes.
        async_socket = PolledSocket(FCP_HOST, FCP_PORT)
        # Knows about running the FCP protocol over async_socket.
        self.connection = FCPConnection(async_socket, True,
                                        callbacks.connection_state)
        # Knows about running requests from a request queue.
        runner = RequestRunner(self.connection, N_CONCURRENT)
        # Knows how to run series of requests to perform operations
        # on an archive in Freenet.
        sm = ArchiveStateMachine(runner, ArchiveUpdateContext())
        sm.transition_callback = callbacks.transition_callback
        sm.monitor_callback = callbacks.monitor_callback
        sm.params['CANCEL_TIME_SECS'] = CANCEL_TIME_SECS

        return sm
コード例 #2
0
    def make_state_machine(self):
        if not self.connection is None:
            self.connection.close()

        callbacks = UICallbacks(FakeUI())
        callbacks.verbosity = 5
        # Knows about reading and writing bytes.
        async_socket = PolledSocket(FCP_HOST, FCP_PORT)
        # Knows about running the FCP protocol over async_socket.
        self.connection = FCPConnection(async_socket, True,
                                        callbacks.connection_state)
        # Knows about running requests from a request queue.
        runner = RequestRunner(self.connection, N_CONCURRENT)
        # Knows how to run series of requests to perform operations
        # on an archive in Freenet.
        sm = ArchiveStateMachine(runner, ArchiveUpdateContext())
        sm.transition_callback = callbacks.transition_callback
        sm.monitor_callback = callbacks.monitor_callback
        sm.params['CANCEL_TIME_SECS'] = CANCEL_TIME_SECS

        return sm
コード例 #3
0
ファイル: infcmds.py プロジェクト: SeekingFor/infocalypse
    if repo is None:
        # For incremental archives.
        ctx = ArchiveUpdateContext()
        update_sm = ArchiveStateMachine(runner, ctx)
    else:
        # For Infocalypse repositories
        ctx = UpdateContext(None)
        ctx.repo = repo
        ctx.ui_ = ui_
        ctx.bundle_cache = cache
        update_sm = UpdateStateMachine(runner, ctx)

    update_sm.params = params.copy()
    update_sm.transition_callback = callbacks.transition_callback
    update_sm.monitor_callback = callbacks.monitor_callback

    # Modify only after copy.
    update_sm.params['FREENET_BUILD'] = runner.connection.node_hello[1][
        'Build']

    return update_sm


def run_until_quiescent(update_sm, poll_secs, close_socket=True):
    """ Run the state machine until it reaches the QUIESCENT state. """
    runner = update_sm.runner
    assert not runner is None
    connection = runner.connection
    assert not connection is None
    raised = True
コード例 #4
0
ファイル: infcmds.py プロジェクト: ArneBab/infocalypse
    if repo is None:
        # For incremental archives.
        ctx = ArchiveUpdateContext()
        update_sm = ArchiveStateMachine(runner, ctx)
    else:
        # For Infocalypse repositories
        ctx = UpdateContext(None)
        ctx.repo = repo
        ctx.ui_ = ui_
        ctx.bundle_cache = cache
        update_sm = UpdateStateMachine(runner, ctx)


    update_sm.params = params.copy()
    update_sm.transition_callback = callbacks.transition_callback
    update_sm.monitor_callback = callbacks.monitor_callback

    # Modify only after copy.
    update_sm.params['FREENET_BUILD'] = runner.connection.node_hello[1]['Build']

    return update_sm

def run_until_quiescent(update_sm, poll_secs, close_socket=True):
    """ Run the state machine until it reaches the QUIESCENT state. """
    runner = update_sm.runner
    assert not runner is None
    connection = runner.connection
    assert not connection is None
    raised = True
    try:
        while update_sm.current_state.name != QUIESCENT: