(data: DataModel)
| 466 | |
| 467 | |
| 468 | def choose_slave_channels(data: DataModel): |
| 469 | chosen_slave_names, chosen_slave_ids = data.get_selected_slave_lists() |
| 470 | widget = ReorderBullet(_("2. Choose slave channels (at least one is required)."), |
| 471 | choices=chosen_slave_names, |
| 472 | choices_id=chosen_slave_ids, |
| 473 | required=True) |
| 474 | |
| 475 | channel_names, channel_ids = data.get_slave_lists() |
| 476 | list_widget = KeyValueBullet(prompt=_("Choose a slave channel to add."), |
| 477 | choices=channel_names, |
| 478 | choices_id=channel_ids) |
| 479 | |
| 480 | while True: |
| 481 | print() |
| 482 | chosen_slave_names, chosen_slave_ids, action = widget.launch() |
| 483 | if action == 'add': |
| 484 | print() |
| 485 | add_channel_name, add_channel_id = list_widget.launch() |
| 486 | add_channel_instance = input(_("Instance name to use with {channel_name}: [{default_instance}]") |
| 487 | .format(channel_name=add_channel_name, |
| 488 | default_instance=_("default instance")) |
| 489 | + " ").strip() |
| 490 | if add_channel_instance: |
| 491 | add_channel_id += "#" + add_channel_instance |
| 492 | |
| 493 | display_name = data.get_instance_display_name(add_channel_id) |
| 494 | if add_channel_id in widget.choices_id: |
| 495 | print_wrapped(_("{instance_name} ({instance_id}) is already enabled. " |
| 496 | "Please try another one.") |
| 497 | .format(instance_name=display_name, instance_id=add_channel_id)) |
| 498 | else: |
| 499 | widget.choices.insert(-2, display_name) |
| 500 | widget.choices_id.insert(-2, add_channel_id) |
| 501 | else: # action == 'submit' |
| 502 | break |
| 503 | data.config['slave_channels'] = chosen_slave_ids |
| 504 | |
| 505 | |
| 506 | def choose_middlewares(data: DataModel): |
no test coverage detected