Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit05342b0

Browse files
committed
tools/mpremote: Support OSError's on targets without errno.
Targets without the `errno` module enabled will not render `OSError`swith the name of the error. Instead they just print the numeric errorcode.Add support for such targets by explicitly recognising certain error codes.Signed-off-by: Damien George <damien@micropython.org>
1 parentda3709a commit05342b0

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

‎tools/mpremote/mpremote/mp_errno.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
importerrno
2+
3+
# This table maps numeric values defined by `py/mperrno.h` to host errno code.
4+
MP_ERRNO_TABLE= {
5+
1:errno.EPERM,
6+
2:errno.ENOENT,
7+
3:errno.ESRCH,
8+
4:errno.EINTR,
9+
5:errno.EIO,
10+
6:errno.ENXIO,
11+
7:errno.E2BIG,
12+
8:errno.ENOEXEC,
13+
9:errno.EBADF,
14+
10:errno.ECHILD,
15+
11:errno.EAGAIN,
16+
12:errno.ENOMEM,
17+
13:errno.EACCES,
18+
14:errno.EFAULT,
19+
15:errno.ENOTBLK,
20+
16:errno.EBUSY,
21+
17:errno.EEXIST,
22+
18:errno.EXDEV,
23+
19:errno.ENODEV,
24+
20:errno.ENOTDIR,
25+
21:errno.EISDIR,
26+
22:errno.EINVAL,
27+
23:errno.ENFILE,
28+
24:errno.EMFILE,
29+
25:errno.ENOTTY,
30+
26:errno.ETXTBSY,
31+
27:errno.EFBIG,
32+
28:errno.ENOSPC,
33+
29:errno.ESPIPE,
34+
30:errno.EROFS,
35+
31:errno.EMLINK,
36+
32:errno.EPIPE,
37+
33:errno.EDOM,
38+
34:errno.ERANGE,
39+
95:errno.EOPNOTSUPP,
40+
97:errno.EAFNOSUPPORT,
41+
98:errno.EADDRINUSE,
42+
103:errno.ECONNABORTED,
43+
104:errno.ECONNRESET,
44+
105:errno.ENOBUFS,
45+
106:errno.EISCONN,
46+
107:errno.ENOTCONN,
47+
110:errno.ETIMEDOUT,
48+
111:errno.ECONNREFUSED,
49+
113:errno.EHOSTUNREACH,
50+
114:errno.EALREADY,
51+
115:errno.EINPROGRESS,
52+
125:errno.ECANCELED,
53+
}

‎tools/mpremote/mpremote/transport.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
# THE SOFTWARE.
2626

27-
importast,errno,hashlib,os,sys
27+
importast,errno,hashlib,os,re,sys
2828
fromcollectionsimportnamedtuple
29+
from .mp_errnoimportMP_ERRNO_TABLE
2930

3031

3132
defstdout_write_bytes(b):
@@ -62,6 +63,16 @@ def _convert_filesystem_error(e, info):
6263
]:
6364
ifestrine.error_output:
6465
returnOSError(code,info)
66+
67+
# Some targets don't render OSError with the name of the errno, so in these
68+
# cases support an explicit mapping of errnos to known numeric codes.
69+
error_lines=e.error_output.splitlines()
70+
match=re.match(r"OSError: (\d+)$",error_lines[-1])
71+
ifmatch:
72+
value=int(match.group(1),10)
73+
ifvalueinMP_ERRNO_TABLE:
74+
returnOSError(MP_ERRNO_TABLE[value],info)
75+
6576
returne
6677

6778

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp