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
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
(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'] 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
def __init__(self, runner, ctx): UpdateStateMachine.__init__(self, runner, ctx) self.states.update(self.new_states())