def __init__(self, name, params, request_runner): FMSBot.__init__(self, name) RequestQueue.__init__(self, request_runner) self.ctx = None self.applier = None self.params = params.copy() self.ui_ = None self.repo = None self.trust = None self.update_sm = None # Why doesn't the base class ctr do this? request_runner.add_queue(self)
def __init__(self, runner, ctx): RequestQueue.__init__(self, runner) StateMachine.__init__(self) self.ctx = None self.set_context(ctx) # Do early. States might depend on ctx. self.states = { QUIESCENT:Quiescent(self, QUIESCENT), # Justing inverting INVERTING_URI:InvertingUri(self, INVERTING_URI, QUIESCENT, FAILING), # Requesting previous graph in order to do insert. INVERTING_URI_4_INSERT:InvertingUri(self, INVERTING_URI_4_INSERT, REQUESTING_URI_4_INSERT, FAILING), REQUESTING_URI_4_INSERT:RequestingUri(self, REQUESTING_URI_4_INSERT, REQUESTING_GRAPH, FAILING), REQUESTING_GRAPH:RequestingGraph(self, REQUESTING_GRAPH, INSERTING_BUNDLES, FAILING), # Inserting INSERTING_BUNDLES:InsertingBundles(self, INSERTING_BUNDLES), INSERTING_GRAPH:InsertingGraph(self, INSERTING_GRAPH, INSERTING_URI, FAILING), INSERTING_URI:InsertingUri(self,INSERTING_URI, FINISHING, FAILING), CANCELING:CleaningUp(self, CANCELING, QUIESCENT), FAILING:CleaningUp(self, FAILING, QUIESCENT), # Requesting REQUESTING_URI:RequestingUri(self, REQUESTING_URI, REQUESTING_BUNDLES, FAILING), REQUESTING_BUNDLES:RequestingBundles(self, REQUESTING_BUNDLES, FINISHING, FAILING), FINISHING:CleaningUp(self, FINISHING, QUIESCENT), # Requesting head info from freenet REQUESTING_URI_4_HEADS:RequestingUri(self, REQUESTING_URI_4_HEADS, REQUIRES_GRAPH_4_HEADS, FAILING), REQUIRES_GRAPH_4_HEADS:RequiresGraph(self, REQUIRES_GRAPH_4_HEADS, REQUESTING_GRAPH_4_HEADS, FINISHING), REQUESTING_GRAPH_4_HEADS:RequestingGraph(self, REQUESTING_GRAPH_4_HEADS, FINISHING, FAILING), # Run and arbitrary StatefulRequest. RUNNING_SINGLE_REQUEST:RunningSingleRequest(self, RUNNING_SINGLE_REQUEST, FINISHING, FAILING), # Copying. # This doesn't verify that the graph chk(s) are fetchable. REQUESTING_URI_4_COPY:RequestingUri(self, REQUESTING_URI_4_COPY, INSERTING_URI, FAILING), } self.current_state = self.get_state(QUIESCENT) self.params = {} # Must not change any state! self.monitor_callback = lambda parent, client, msg: None runner.add_queue(self)
def __init__(self, runner, ctx): RequestQueue.__init__(self, runner) StateMachine.__init__(self) self.ctx = None self.set_context(ctx) # Do early. States might depend on ctx. self.states = { QUIESCENT: Quiescent(self, QUIESCENT), # Justing inverting INVERTING_URI: InvertingUri(self, INVERTING_URI, QUIESCENT, FAILING), # Requesting previous graph in order to do insert. INVERTING_URI_4_INSERT: InvertingUri(self, INVERTING_URI_4_INSERT, REQUESTING_URI_4_INSERT, FAILING), REQUESTING_URI_4_INSERT: RequestingUri(self, REQUESTING_URI_4_INSERT, REQUESTING_GRAPH, FAILING), REQUESTING_GRAPH: RequestingGraph(self, REQUESTING_GRAPH, INSERTING_BUNDLES, FAILING), # Inserting INSERTING_BUNDLES: InsertingBundles(self, INSERTING_BUNDLES), INSERTING_GRAPH: InsertingGraph(self, INSERTING_GRAPH, INSERTING_URI, FAILING), INSERTING_URI: InsertingUri(self, INSERTING_URI, FINISHING, FAILING), CANCELING: CleaningUp(self, CANCELING, QUIESCENT), FAILING: CleaningUp(self, FAILING, QUIESCENT), # Requesting REQUESTING_URI: RequestingUri(self, REQUESTING_URI, REQUESTING_BUNDLES, FAILING), REQUESTING_BUNDLES: RequestingBundles(self, REQUESTING_BUNDLES, FINISHING, FAILING), FINISHING: CleaningUp(self, FINISHING, QUIESCENT), # Requesting head info from freenet REQUESTING_URI_4_HEADS: RequestingUri(self, REQUESTING_URI_4_HEADS, REQUIRES_GRAPH_4_HEADS, FAILING), REQUIRES_GRAPH_4_HEADS: RequiresGraph(self, REQUIRES_GRAPH_4_HEADS, REQUESTING_GRAPH_4_HEADS, FINISHING), REQUESTING_GRAPH_4_HEADS: RequestingGraph(self, REQUESTING_GRAPH_4_HEADS, FINISHING, FAILING), # Run and arbitrary StatefulRequest. RUNNING_SINGLE_REQUEST: RunningSingleRequest(self, RUNNING_SINGLE_REQUEST, FINISHING, FAILING), # Copying. # This doesn't verify that the graph chk(s) are fetchable. REQUESTING_URI_4_COPY: RequestingUri(self, REQUESTING_URI_4_COPY, INSERTING_URI, FAILING), } self.current_state = self.get_state(QUIESCENT) self.params = {} # Must not change any state! self.monitor_callback = lambda parent, client, msg: None runner.add_queue(self)