Hi all,
I wonder if the Makefile and mpconfigport.h macro definitions for enabling features in the uos module are documented anywhere?
Cheers!
enabling uos features in unix port
Re: enabling uos features in unix port
Not that I'm aware of.
uos is a bit complicated because it varies between ports.
What would you like to enable?
uos is a bit complicated because it varies between ports.
What would you like to enable?
Re: enabling uos features in unix port
I was looking for getcwd().
I can work the rest out from an example.
I've tried defining a few config macros here and there without much success but I haven't really got time to figure it all out.
I'm building on WSL (Linux HPZ17G5-3G18 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux)
micropython
python3
I can work the rest out from an example.
I've tried defining a few config macros here and there without much success but I haven't really got time to figure it all out.
I'm building on WSL (Linux HPZ17G5-3G18 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux)
micropython
Code: Select all
>>> dir(uos)
['__class__', '__name__', 'remove', 'errno', 'getenv', 'ilistdir', 'mkdir', 'stat', 'statvfs', 'system']
Code: Select all
>>> dir(os)
['CLD_CONTINUED', 'CLD_DUMPED', 'CLD_EXITED', 'CLD_TRAPPED', 'DirEntry', 'EX_CANTCREAT', 'EX_CONFIG', 'EX_DATAERR',
'EX_IOERR', 'EX_NOHOST', 'EX_NOINPUT', 'EX_NOPERM', 'EX_NOUSER', 'EX_OK', 'EX_OSERR', 'EX_OSFILE', 'EX_PROTOCOL',
'EX_SOFTWARE', 'EX_TEMPFAIL', 'EX_UNAVAILABLE', 'EX_USAGE', 'F_LOCK', 'F_OK', 'F_TEST', 'F_TLOCK', 'F_ULOCK', 'GRND_NONBLOCK',
'GRND_RANDOM', 'MutableMapping', 'NGROUPS_MAX', 'O_ACCMODE', 'O_APPEND', 'O_ASYNC', 'O_CLOEXEC', 'O_CREAT', 'O_DIRECT',
'O_DIRECTORY', 'O_DSYNC', 'O_EXCL', 'O_LARGEFILE', 'O_NDELAY', 'O_NOATIME', 'O_NOCTTY', 'O_NOFOLLOW', 'O_NONBLOCK',
'O_PATH', 'O_RDONLY', 'O_RDWR', 'O_RSYNC', 'O_SYNC', 'O_TMPFILE', 'O_TRUNC', 'O_WRONLY', 'POSIX_FADV_DONTNEED',
'POSIX_FADV_NOREUSE', 'POSIX_FADV_NORMAL', 'POSIX_FADV_RANDOM', 'POSIX_FADV_SEQUENTIAL', 'POSIX_FADV_WILLNEED',
'PRIO_PGRP', 'PRIO_PROCESS', 'PRIO_USER', 'P_ALL', 'P_NOWAIT', 'P_NOWAITO', 'P_PGID', 'P_PID', 'P_WAIT', 'PathLike',
'RTLD_DEEPBIND', 'RTLD_GLOBAL', 'RTLD_LAZY', 'RTLD_LOCAL', 'RTLD_NODELETE', 'RTLD_NOLOAD', 'RTLD_NOW', 'R_OK',
'SCHED_BATCH', 'SCHED_FIFO', 'SCHED_IDLE', 'SCHED_OTHER', 'SCHED_RESET_ON_FORK', 'SCHED_RR', 'SEEK_CUR', 'SEEK_DATA',
'SEEK_END', 'SEEK_HOLE', 'SEEK_SET', 'ST_APPEND', 'ST_MANDLOCK', 'ST_NOATIME', 'ST_NODEV', 'ST_NODIRATIME', 'ST_NOEXEC',
'ST_NOSUID', 'ST_RDONLY', 'ST_RELATIME', 'ST_SYNCHRONOUS', 'ST_WRITE', 'TMP_MAX', 'WCONTINUED', 'WCOREDUMP', 'WEXITED',
'WEXITSTATUS', 'WIFCONTINUED', 'WIFEXITED', 'WIFSIGNALED', 'WIFSTOPPED', 'WNOHANG', 'WNOWAIT', 'WSTOPPED', 'WSTOPSIG',
'WTERMSIG', 'WUNTRACED', 'W_OK', 'XATTR_CREATE', 'XATTR_REPLACE', 'XATTR_SIZE_MAX', 'X_OK', '_Environ', '__all__', '__builtins__',
'__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_execvpe', '_exists', '_exit', '_fspath', '_fwalk',
'_get_exports_list', '_putenv', '_spawnvef', '_unsetenv', '_wrap_close', 'abc', 'abort', 'access', 'altsep', 'chdir', 'chmod', 'chown', 'chroot',
'close', 'closerange', 'confstr', 'confstr_names', 'cpu_count', 'ctermid', 'curdir', 'defpath', 'device_encoding', 'devnull', 'dup', 'dup2', 'environ',
'environb', 'errno', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve', 'execvp', 'execvpe', 'extsep', 'fchdir', 'fchmod', 'fchown',
'fdatasync', 'fdopen', 'fork', 'forkpty', 'fpathconf', 'fsdecode', 'fsencode', 'fspath', 'fstat', 'fstatvfs', 'fsync', 'ftruncate', 'fwalk', 'get_blocking',
'get_exec_path', 'get_inheritable', 'get_terminal_size', 'getcwd', 'getcwdb', 'getegid', 'getenv', 'getenvb', 'geteuid', 'getgid', 'getgrouplist',
'getgroups', 'getloadavg', 'getlogin', 'getpgid', 'getpgrp', 'getpid', 'getppid', 'getpriority', 'getrandom', 'getresgid', 'getresuid', 'getsid', 'getuid',
'getxattr', 'initgroups', 'isatty', 'kill', 'killpg', 'lchown', 'linesep', 'link', 'listdir', 'listxattr', 'lockf', 'lseek', 'lstat', 'major', 'makedev', 'makedirs',
'minor', 'mkdir', 'mkfifo', 'mknod', 'name', 'nice', 'open', 'openpty', 'pardir', 'path', 'pathconf', 'pathconf_names', 'pathsep', 'pipe', 'pipe2',
'popen', 'posix_fadvise', 'posix_fallocate', 'pread', 'putenv', 'pwrite', 'read', 'readlink', 'readv', 'remove', 'removedirs', 'removexattr', 'rename',
'renames', 'replace', 'rmdir', 'scandir', 'sched_get_priority_max', 'sched_get_priority_min', 'sched_getaffinity', 'sched_getparam',
'sched_getscheduler', 'sched_param', 'sched_rr_get_interval', 'sched_setaffinity', 'sched_setparam', 'sched_setscheduler', 'sched_yield',
'sendfile', 'sep', 'set_blocking', 'set_inheritable', 'setegid', 'seteuid', 'setgid', 'setgroups', 'setpgid', 'setpgrp', 'setpriority', 'setregid', 'setresgid',
'setresuid', 'setreuid', 'setsid', 'setuid', 'setxattr', 'spawnl', 'spawnle', 'spawnlp', 'spawnlpe', 'spawnv', 'spawnve', 'spawnvp', 'spawnvpe', 'st',
'stat', 'stat_float_times', 'stat_result', 'statvfs', 'statvfs_result', 'strerror', 'supports_bytes_environ', 'supports_dir_fd',
'supports_effective_ids', 'supports_fd', 'supports_follow_symlinks', 'symlink', 'sync', 'sys', 'sysconf', 'sysconf_names', 'system', 'tcgetpgrp',
'tcsetpgrp', 'terminal_size', 'times', 'times_result', 'truncate', 'ttyname', 'umask', 'uname', 'uname_result', 'unlink', 'unsetenv', 'urandom',
'utime', 'wait', 'wait3', 'wait4', 'waitid', 'waitid_result', 'waitpid', 'walk', 'write', 'writev']
>>>
Re: enabling uos features in unix port
Did you see the os module in micropython-lib, which provides a lot of os funtions, including getcwd(). It is available via 'import os'
Code: Select all
MicroPython v1.12-87-g96716b46e-dirty on 2020-01-24; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import os
>>> dir(os)
['__class__', '__name__', 'close', 'const', 'open', 'read', 'remove', 'sep', 'write', '__file__', '__path__',
'array', 'getenv', 'ilistdir', 'mkdir', 'name', 'path', 'rename', 'rmdir', 'stat', 'struct', 'system', 'uos',
'urandom', 'unlink', 'errno_', 'stat_', 'ffilib', 'R_OK', 'W_OK', 'X_OK', 'F_OK', 'O_ACCMODE',
'O_RDONLY', 'O_WRONLY', 'O_RDWR', 'O_CREAT', 'O_EXCL', 'O_NOCTTY', 'O_TRUNC',
'O_APPEND', 'O_NONBLOCK', 'P_WAIT', 'P_NOWAIT', 'error', 'curdir', 'pardir', 'environ', 'libc',
'chdir_', 'chdir', 'mkdir_', 'rename_', 'unlink_', 'rmdir_', 'getcwd_', 'getcwd', 'opendir_', 'readdir_',
'open_', 'read_', 'write_', 'close_', 'dup_', 'dup', 'access_', 'access', 'fork_', 'fork', 'pipe_', 'pipe',
'_exit_', '_exit', 'getpid_', 'getpid', 'waitpid_', 'waitpid', 'system_', 'execvp_', 'execvp', 'kill_', 'kill',
'getenv_', 'check_error', 'raise_error', 'makedirs', 'listdir', 'fsdecode', 'walk', 'fsencode', 'popen', 'spawnvp']
>>>
Re: enabling uos features in unix port
this is mine ...
Code: Select all
micropython/ports/unix$ micropython
MicroPython 1d9dd9aa5-dirty on 2020-01-22; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>>
>>>
>>>
>>>
>>> import os
Traceback (most recent call last):
File "<stdin>", in <module>
ImportError: module not found
Re: enabling uos features in unix port
You have to install micropython.lib or the required packages on your system. See the README in https://github.com/micropython/micropython-lib
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: enabling uos features in unix port
Code: Select all
>>> import upip
>>> upip.install('micropython-os')
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: enabling uos features in unix port
cool! thanks, I didn't know that
very handy!
very handy!