Skip to content

Commit 9a856b0

Browse files
committed
connections/ev3dev: Flatten directory structure.
This makes it simply run one script similar to powered up hubs.
1 parent befdfe9 commit 9a856b0

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Changed
10+
- Changed EV3 script runner to just copy the script instead of replicating
11+
the local directory structure on the brick.
12+
913
## [1.0.0-alpha.35] - 2023-02-10
1014

1115
### Added

pybricksdev/connections/ev3dev.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Copyright (c) 2021-2022 The Pybricks Authors
33

44
import asyncio
5-
import os
6-
75
import asyncssh
6+
import os
7+
import pathlib
88

99

1010
class EV3Connection:
@@ -56,23 +56,10 @@ async def download(self, local_path):
5656
Arguments:
5757
local_path (str):
5858
Path to the file to be downloaded. Relative to current working
59-
directory. This same tree will be created on the EV3 if it
60-
does not already exist.
59+
directory.
6160
"""
62-
# Compute paths
63-
dirs, file_name = os.path.split(local_path)
64-
65-
# Make sure same directory structure exists on EV3
66-
if not await self.client.sftp.exists(self.abs_path(dirs)):
67-
# If not, make the folders one by one
68-
total = ""
69-
for name in dirs.split(os.sep):
70-
total = os.path.join(total, name)
71-
if not await self.client.sftp.exists(self.abs_path(total)):
72-
await self.client.sftp.mkdir(self.abs_path(total))
73-
7461
# Send script to EV3
75-
remote_path = self.abs_path(local_path)
62+
remote_path = self.abs_path(pathlib.Path(local_path).name)
7663
await self.client.sftp.put(local_path, remote_path)
7764
return remote_path
7865

0 commit comments

Comments
 (0)