def _mark_current_work_completed(self, capture=None): sampleset = self._get_current_sampleset() sampleset.completed = timezone.now() if capture: sampleset.success = True sampleset.data = capture else: # Sampleset data collection failed, # create a new sampleset for the same attack element s = SampleSet( round=sampleset.round, candidatealphabet=sampleset.candidatealphabet, alignmentalphabet=sampleset.alignmentalphabet ) s.save() sampleset.save()
def _create_round_samplesets(self): state = { 'knownalphabet': self._round.knownalphabet, 'knownsecret': self._round.knownsecret } candidate_alphabets = self._build_candidates(state) alignmentalphabet = list(self._round.victim.target.alignmentalphabet) random.shuffle(alignmentalphabet) alignmentalphabet = ''.join(alignmentalphabet) logger.debug('\tAlignment alphabet: {}'.format(alignmentalphabet)) for candidate in candidate_alphabets: sampleset = SampleSet( round=self._round, candidatealphabet=candidate, alignmentalphabet=alignmentalphabet ) sampleset.save()