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
Exemple #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
Exemple #3
0
                                   callbacks.connection_state)
    except socket.error, err:  # Not an IOError until 2.6.
        ui_.warn("Connection to FCP server [%s:%i] failed.\n" %
                 (params['FCP_HOST'], params['FCP_PORT']))
        raise err
    except IOError, err:
        ui_.warn("Connection to FCP server [%s:%i] failed.\n" %
                 (params['FCP_HOST'], params['FCP_PORT']))
        raise err

    runner = RequestRunner(connection, params['N_CONCURRENT'])

    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']
Exemple #4
0
                                   callbacks.connection_state)
    except socket.error, err: # Not an IOError until 2.6.
        ui_.warn("Connection to FCP server [%s:%i] failed.\n"
                % (params['FCP_HOST'], params['FCP_PORT']))
        raise err
    except IOError, err:
        ui_.warn("Connection to FCP server [%s:%i] failed.\n"
                % (params['FCP_HOST'], params['FCP_PORT']))
        raise err

    runner = RequestRunner(connection, params['N_CONCURRENT'])

    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']