def write_default_options(): settings = constants.SETTINGS keys = settings.allKeys() if 'rel_symbol_length' not in keys: settings.setValue('rel_symbol_length', 0) if 'default_view' not in keys: settings.setValue('default_view', 0) if 'num_sending_repeats' not in keys: settings.setValue('num_sending_repeats', 0) if 'show_pause_as_time' not in keys: settings.setValue('show_pause_as_time', False) settings.sync( ) # Ensure conf dir is created to have field types in place if not os.path.isfile(constants.FIELD_TYPE_SETTINGS): FieldType.save_to_xml(FieldType.default_field_types()) bh = BackendHandler() for be in bh.device_backends.values(): be.write_settings()
def setUp(self): self.field_types = FieldType.default_field_types() self.preamble_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.PREAMBLE) self.sync_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.SYNC) self.length_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.LENGTH) self.sequence_number_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.SEQUENCE_NUMBER) self.dst_address_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.DST_ADDRESS) self.src_address_field_type = self.__field_type_with_function(self.field_types, FieldType.Function.SRC_ADDRESS) self.protocol = ProtocolAnalyzer(None) with open(get_path_for_data_file("awre_consistent_addresses.txt")) as f: for line in f: self.protocol.messages.append(Message.from_plain_bits_str(line.replace("\n", ""))) self.protocol.messages[-1].message_type = self.protocol.default_message_type # Assign participants alice = Participant("Alice", "A") bob = Participant("Bob", "B") alice_indices = {1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 20, 22, 23, 26, 27, 30, 31, 34, 35, 38, 39, 41} for i, message in enumerate(self.protocol.messages): message.participant = alice if i in alice_indices else bob self.participants = [alice, bob] self.zero_crc_protocol = ProtocolAnalyzer(None) with open(get_path_for_data_file("awre_zeroed_crc.txt")) as f: for line in f: self.zero_crc_protocol.messages.append(Message.from_plain_bits_str(line.replace("\n", ""))) self.zero_crc_protocol.messages[-1].message_type = self.protocol.default_message_type for i, message in enumerate(self.zero_crc_protocol.messages): message.participant = alice if i in alice_indices else bob
def write_default_options(): settings = constants.SETTINGS keys = settings.allKeys() if 'default_view' not in keys: settings.setValue('default_view', 0) if 'num_sending_repeats' not in keys: settings.setValue('num_sending_repeats', 0) if 'show_pause_as_time' not in keys: settings.setValue('show_pause_as_time', False) settings.sync() # Ensure conf dir is created to have field types in place if not os.path.isfile(constants.FIELD_TYPE_SETTINGS): FieldType.save_to_xml(FieldType.default_field_types()) bh = BackendHandler() for be in bh.device_backends.values(): be.write_settings()