Skip to content

fix generating streams parameters (ftp, log_files was broken) #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mavsdk/ftp/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions mavsdk/log_files/log_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mavsdk/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def follow_me(self) -> follow_me.FollowMe:
def ftp(self) -> ftp.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.Geofence:
Expand Down
16 changes: 16 additions & 0 deletions other/templates/py/stream.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down