def enter(self, dummy): """ Implementation of State virtual. """ #require_state(from_state, QUIESCENT) #print "REQUEST_URI:" #print self.parent.ctx['REQUEST_URI'] request_uri = self.parent.ctx['REQUEST_URI'] if (is_usk(request_uri) and self.parent.params.get('AGGRESSIVE_SEARCH', False)): request_uri = get_negative_usk(request_uri) if (is_usk(request_uri) and self.parent.params['NO_SEARCH']): request_uris = make_frozen_uris(request_uri, False) self.parent.ctx.ui_.status("Request URI index searching " + "disabled.\n") else: request_uris = make_search_uris(request_uri) for uri in request_uris: #[uri, tries, is_insert, raw_data, mime_type, last_msg] if self.parent.params.get('DUMP_URIS', False): self.parent.ctx.ui_.status("REQUEST URI: %s\n" % uri) self.queue([uri, 0, False, None, None, None]) self.required_successes = 1 #len(self.results) # Hmmm fix, but how # So we don't implictly favor one by requesting it first. random.shuffle(self.current_candidates)
def enter(self, from_state): """ Implementation of State virtual. This creates the binary rep for the top level key data and starts inserting it into Freenet. """ if not hasattr(from_state, 'get_top_key_tuple'): raise Exception("Illegal Transition from: %s" % from_state.name) # DCI: Retest non-archive stuff! # Cache *before* the possible transition below. top_key_tuple = from_state.get_top_key_tuple() self.cached_top_key_tuple = top_key_tuple # hmmmm... if (self.parent.ctx['INSERT_URI'] is None and self.parent.ctx.get('REINSERT', 0) > 0): # Hmmmm... hackery to deal with reinsert w/o insert uri self.parent.transition(self.success_state) return assert not self.parent.ctx['INSERT_URI'] is None if self.parent.params.get('DUMP_TOP_KEY', False): self.topkey_funcs.dump_top_key_tuple(top_key_tuple, self.parent.ctx.ui_.status) salt = {0:0x00, 1:0xff} # grrr.... less code. insert_uris = make_frozen_uris(self.parent.ctx['INSERT_URI'], should_increment(self)) assert len(insert_uris) < 3 for index, uri in enumerate(insert_uris): if self.parent.params.get('DUMP_URIS', False): self.parent.ctx.ui_.status("INSERT_URI: %s\n" % uri) self.queue([uri, 0, True, self.topkey_funcs.top_key_tuple_to_bytes(top_key_tuple, salt[index]), None, None]) self.required_successes = len(insert_uris)
def enter(self, from_state): """ Implementation of State virtual. This creates the binary rep for the top level key data and starts inserting it into Freenet. """ if not hasattr(from_state, 'get_top_key_tuple'): raise Exception("Illegal Transition from: %s" % from_state.name) # DCI: Retest non-archive stuff! # Cache *before* the possible transition below. top_key_tuple = from_state.get_top_key_tuple() self.cached_top_key_tuple = top_key_tuple # hmmmm... if (self.parent.ctx['INSERT_URI'] is None and self.parent.ctx.get('REINSERT', 0) > 0): # Hmmmm... hackery to deal with reinsert w/o insert uri self.parent.transition(self.success_state) return assert not self.parent.ctx['INSERT_URI'] is None if self.parent.params.get('DUMP_TOP_KEY', False): self.topkey_funcs.dump_top_key_tuple(top_key_tuple, self.parent.ctx.ui_.status) salt = {0: 0x00, 1: 0xff} # grrr.... less code. insert_uris = make_frozen_uris(self.parent.ctx['INSERT_URI'], should_increment(self)) assert len(insert_uris) < 3 for index, uri in enumerate(insert_uris): if self.parent.params.get('DUMP_URIS', False): self.parent.ctx.ui_.status("INSERT_URI: %s\n" % uri) self.queue([ uri, 0, True, self.topkey_funcs.top_key_tuple_to_bytes( top_key_tuple, salt[index]), None, None ]) self.required_successes = len(insert_uris)