Executing external program on Linux

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Executing external program on Linux

Post by bmarkus » Sat Aug 08, 2015 10:08 am

Hi,

how can I execute an external program/os shell from the Unix version?

Thanks... Béla
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Executing external program on Linux

Post by pfalcon » Sat Aug 08, 2015 11:00 am

Just the same as usual - e.g. os.system(), os.pipe(). There's no "subprocess" module currently.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: Executing external program on Linux

Post by bmarkus » Sat Aug 08, 2015 11:42 am

Thanks, os.system() and os.pipe() is suitable. On our TC (Tiny Core) Linux we have several applications written in shell (BusyBox ASH). In general it is OK, but there are few more complex cases where ASH programming is a pain. I think micropython can be a good choice to migrate shell scripts to Python, but need some work to port scripts and make an evaluation.
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Executing external program on Linux

Post by pfalcon » Sat Aug 08, 2015 12:20 pm

That's exactly the usecase for the unix version of MicroPython, I e.g. wanted to be able to write Python scripts/apps for OpenWRT which would work with just builtin flash, where CPython just won't fit. Feel free to share your experiences, report missing functionality to https://github.com/micropython/micropython-lib/issues , or even better, contribute missing parts ;-).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: Executing external program on Linux

Post by bmarkus » Sat Aug 08, 2015 5:41 pm

Good to see others are doing the same. Tested, os module works fine, so I have everything to start testing some code on the Raspberry Pi with piCore Linux.
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

User avatar
bmarkus
Posts: 111
Joined: Tue Oct 21, 2014 5:58 am

Re: Executing external program on Linux

Post by bmarkus » Wed Aug 19, 2015 6:27 am

So far it looks good. I'm installing extensions during startup dynamically using a dictionary and lists. The only issue is the low default RAM size in UNIX build, 128k. I'm running out memory frequently even with moderate size and simple dicts. Running gc explicitely helps a bit.

I opened a ticket to increase default size.

https://github.com/micropython/micropython/issues/1433
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)

Post Reply