From 4e3154ba21a385bc97d15985c413e1dc17e4dfb5 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 4 Jul 2014 23:48:08 +0300 Subject: [PATCH] os: Add system(). --- os/metadata.txt | 2 +- os/os/__init__.py | 5 +++++ os/setup.py | 2 +- os/test_system.py | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 os/test_system.py diff --git a/os/metadata.txt b/os/metadata.txt index 6480f592..c485954e 100644 --- a/os/metadata.txt +++ b/os/metadata.txt @@ -1,5 +1,5 @@ srctype = micropython-lib type = package -version = 0.1.2 +version = 0.1.3 author = Paul Sokolovsky depends = libc diff --git a/os/os/__init__.py b/os/os/__init__.py index 10a00e2b..eb3cfee4 100644 --- a/os/os/__init__.py +++ b/os/os/__init__.py @@ -28,6 +28,7 @@ pipe_ = libc.func("i", "pipe", "p") _exit_ = libc.func("v", "_exit", "i") getpid_ = libc.func("i", "getpid", "") waitpid_ = libc.func("i", "waitpid", "ipi") +system_ = libc.func("i", "system", "s") R_OK = const(4) W_OK = const(2) @@ -167,6 +168,10 @@ def waitpid(pid, opts): check_error(r) return (r, a[0]) +def system(command): + r = system_(command) + check_error(r) + return r def fsencode(s): if type(s) is bytes: diff --git a/os/setup.py b/os/setup.py index 4afb6894..8ef77b95 100644 --- a/os/setup.py +++ b/os/setup.py @@ -6,7 +6,7 @@ from setuptools import setup setup(name='micropython-os', - version='0.1.2', + version='0.1.3', description='os module for MicroPython', long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.", url='https://github.com/micropython/micropython/issues/405', diff --git a/os/test_system.py b/os/test_system.py new file mode 100644 index 00000000..e765026e --- /dev/null +++ b/os/test_system.py @@ -0,0 +1,4 @@ +import os + +print("Executing ls -l:") +os.system("ls -l")