diff --git a/Drone/client.py b/Drone/client.py index 73a6188..c7fe3e6 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -216,8 +216,10 @@ def _command_config_write(*args, **kwargs): @messaging.request_callback("config") def _response_config(*args, **kwargs): - response = {"config": active_client.config.full_dict(), - "configspec": dict(active_client.config.config.configspec)} + send_configspec = kwargs.get("send_configspec", False) + response = {"config": active_client.config.full_dict()} + if send_configspec: + response.update({"configspec": dict(active_client.config.config.configspec)}) return response @messaging.request_callback("id") diff --git a/Server/copter_table.py b/Server/copter_table.py index 06b6c7b..a6182e4 100644 --- a/Server/copter_table.py +++ b/Server/copter_table.py @@ -145,6 +145,10 @@ class CopterTableWidget(QTableView): edit_config.triggered.connect(partial(self.edit_copter_config, item)) menu.addAction(edit_config) + copy_config = QAction("Copy config to selected") + copy_config.triggered.connect(partial(self.copy_config, item)) + menu.addAction(copy_config) + if item is None: edit_config.setDisabled(True) @@ -153,7 +157,20 @@ class CopterTableWidget(QTableView): @pyqtSlot() def edit_copter_config(self, copter): dialog = ConfigDialog() - copter.client.get_response("config", dialog.call_copter_dialog) + copter.client.get_response("config", dialog.call_copter_dialog, request_kwargs={'send_configspec': True}) + + @pyqtSlot() + def copy_config(self, copter): + def send_callback(client, value): + config = value["config"] + config.pop("PRIVATE", None) # delete private section + + for _copter in self.model.user_selected(): + if _copter.client is client: + continue # don't send config back to the same copter + _copter.client.send_message("config", kwargs={"config": config, "mode": "modify"}) + + copter.client.get_response("config", send_callback, request_kwargs={'send_configspec': False}) # def _selfcheck_shortener(self, data): # TODO!!! # shortened = []