Exemplo n.º 1
0
def setup_sm(ui_, repo, runner, params):
    """ INTERNAL: Helper function which sets up an UpdateStateMachine
        instance. """
    assert is_writable(os.path.expanduser(params['TMP_DIR']))

    verbosity = params.get('VERBOSITY', 1)
    set_debug_vars(verbosity, params)

    callbacks = UICallbacks(ui_)
    callbacks.verbosity = verbosity
    # DCI: bundle cache needed for inserting?
    cache = BundleCache(repo, ui_, params['TMP_DIR'])

    # 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
Exemplo n.º 2
0
def setup_sm(ui_, repo, runner, params):
    """ INTERNAL: Helper function which sets up an UpdateStateMachine
        instance. """
    assert is_writable(os.path.expanduser(params['TMP_DIR']))

    verbosity = params.get('VERBOSITY', 1)
    set_debug_vars(verbosity, params)

    callbacks = UICallbacks(ui_)
    callbacks.verbosity = verbosity
    # DCI: bundle cache needed for inserting?
    cache = BundleCache(repo, ui_, params['TMP_DIR'])

    # 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
Exemplo n.º 3
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
Exemplo n.º 4
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