Hi team, is there any OSError code list with translation what each code implies? As that I feel the codes are not completed yet.
Regards,
Cahe https://dltutuapp.com/tutuapp-download/ https://showbox.run/ https://kodi.software/
Any OSError Codes as of now?
-
- Posts: 166
- Joined: Tue Nov 07, 2017 11:45 pm
Re: Any OSError Codes as of now?
They are just text versions of the constants defined in file errno.h. micropython sticks to these eg ENODEV to remain lean.
If you need a translator to convert these to english you need to write a C program
If you need a translator to convert these to english you need to write a C program
Re: Any OSError Codes as of now?
Using regular CPython:
These aren't included in MicroPython because it's just a lot of space to take up.
Code: Select all
>>> import os
>>> os.strerror(27)
'File too large'
-
- Posts: 1
- Joined: Sun Jan 17, 2021 7:03 pm
- Contact:
Re: Any OSError Codes as of now?
I want to handle specific OSError codes like this:
try:
os.scandir()
except OSPermissionError as error:
# Only catch errno.EACCES, errno.EPERM
handle_permission_error()
except OSFileNotFoundError as error:
# Only catch errno.ENOENT
handle_FileNotFoundError_error()
Can this be done in python? shareit get-vidmateapk.com
try:
os.scandir()
except OSPermissionError as error:
# Only catch errno.EACCES, errno.EPERM
handle_permission_error()
except OSFileNotFoundError as error:
# Only catch errno.ENOENT
handle_FileNotFoundError_error()
Can this be done in python? shareit get-vidmateapk.com
Last edited by vicyclefive on Thu Jan 21, 2021 6:51 pm, edited 1 time in total.
Re: Any OSError Codes as of now?
I think you need to do something like:
Code: Select all
EFOO = const(1)
try:
os.scandir()
except OSError as error:
if error.args[0] == EFOO:
# handle foo
elif ...
Re: Any OSError Codes as of now?
Code: Select all
os.scandir()
There are a large number of possible errors that could be part of the
Code: Select all
OSError
Code: Select all
class OSPermissionError(Exception):
pass
class OSFileNotFoundError(Exception):
pass
try:
os.scandir()
except OSError as error:
# Not found
if error.errno == errno.ENOENT:
raise OSFileNotFoundError()
# Permissions Error
elif error.errno in [errno.EPERM, errno.EACCES]:
raise OSPermissionError()
else:
raise
https://gbapps.net