From 9b4750460a10e25608f0e5da015cee7dae86b403 Mon Sep 17 00:00:00 2001 From: Yuriy Homyakov Date: Thu, 4 Jun 2020 15:30:22 +0300 Subject: [PATCH] fix streams parameters (ftp upload/download, log_files download_log_file), fix ftp plugin key --- mavsdk/generated/ftp.py | 4 ++++ mavsdk/generated/log_files.py | 2 ++ mavsdk/system.py | 2 +- other/templates/py/stream.j2 | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mavsdk/generated/ftp.py b/mavsdk/generated/ftp.py index e8e77339..fa10add5 100644 --- a/mavsdk/generated/ftp.py +++ b/mavsdk/generated/ftp.py @@ -345,6 +345,8 @@ async def download(self, remote_file_path, local_dir): """ request = ftp_pb2.SubscribeDownloadRequest() + request.remote_file_path = remote_file_path + request.local_dir = local_dir download_stream = self._stub.SubscribeDownload(request) try: @@ -393,6 +395,8 @@ async def upload(self, local_file_path, remote_dir): """ request = ftp_pb2.SubscribeUploadRequest() + request.local_file_path = local_file_path + request.remote_dir = remote_dir upload_stream = self._stub.SubscribeUpload(request) try: diff --git a/mavsdk/generated/log_files.py b/mavsdk/generated/log_files.py index 87e68dcd..8445738c 100644 --- a/mavsdk/generated/log_files.py +++ b/mavsdk/generated/log_files.py @@ -392,6 +392,8 @@ async def download_log_file(self, id, path): """ request = logFiles_pb2.SubscribeDownloadLogFileRequest() + request.id = id + request.path = path download_log_file_stream = self._stub.SubscribeDownloadLogFile(request) try: diff --git a/mavsdk/system.py b/mavsdk/system.py index 40361dc2..6882ee20 100644 --- a/mavsdk/system.py +++ b/mavsdk/system.py @@ -132,7 +132,7 @@ def follow_me(self) -> FollowMe: def ftp(self) -> Ftp: if "ftp" not in self._plugins: raise RuntimeError(self.error_uninitialized("Ftp")) - return self._plugins["Ftp"] + return self._plugins["ftp"] @property def geofence(self) -> Geofence: diff --git a/other/templates/py/stream.j2 b/other/templates/py/stream.j2 index 2c2a6186..db187a95 100644 --- a/other/templates/py/stream.j2 +++ b/other/templates/py/stream.j2 @@ -25,6 +25,22 @@ async def {{ name.lower_snake_case }}(self{% for param in params %}, {{ param.na """ request = {{ plugin_name.lower_camel_case }}_pb2.Subscribe{{ name.upper_camel_case }}Request() + {% for param in params %} + {%- if param.type_info.is_primitive -%} + request.{{ param.name.lower_snake_case }} = {{ param.name.lower_snake_case }} + {%- else -%} + {% if param.type_info.is_repeated %} + rpc_elems_list = [] + for elem in {{ param.name.lower_snake_case }}: + rpc_elem = {{ plugin_name.lower_snake_case }}_pb2.{{ param.type_info.inner_name }}() + elem.translate_to_rpc(rpc_elem) + rpc_elems_list.append(rpc_elem) + request.{{ param.name.lower_snake_case }}.extend(rpc_elems_list) + {% else %} + {{ param.name.lower_snake_case }}.translate_to_rpc(request.{{ param.name.lower_snake_case }}) + {% endif %} + {% endif %} + {% endfor -%} {{ name.lower_snake_case }}_stream = self._stub.Subscribe{{ name.upper_camel_case }}(request) try: