# Sandbox python app

**URL:** <https://forum.legato.io/t/sandbox-python-app/2976>\
**Category:** Legato Application Framework\
**Created:** [January 20, 2018, 1:57pm UTC](https://forum.legato.io/t/sandbox-python-app/2976 "2018-01-20T13:57:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GustavoCarlos](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/gustavocarlos/32/295_2.png) [@GustavoCarlos](https://forum.legato.io/u/GustavoCarlos)\
**Post date:** [January 20, 2018, 1:57pm UTC](https://forum.legato.io/t/sandbox-python-app/2976/1 "2018-01-20T13:57:56Z")

</div>

Hello,

I am new in the development of legato applications, I had configured my environment and tried to run some legato apps writen in C like the documentation and it works fine.

So I was following the steps in this link to put a python code to run on sandbox  
[http://legato.io/legato-docs/latest/howToSecuritySandboxConfigSample.html](http://legato.io/legato-docs/latest/howToSecuritySandboxConfigSample.html)

I could create the app and install it on the target but it does not work and I got the following messages

**Jan 6 01:00:24 fx30 user.warn Legato: -WRN- | supervisor[511]/supervisor T=main | app.c app\_SigChildHandler() 3373 | Process ‘python’ in app ‘helloPython’ faulted: Ignored.**  
**Jan 6 01:00:24 fx30 user.info Legato: INFO | supervisor[511]/supervisor T=main | apps.c DeactivateAppContainer() 349 | Application ‘helloPython’ has stopped.**

My module is the FX30, anybody could tell me the best way to track where the problem is?

Thanks in advance

Gustavo

---

<div class="post-metadata">

**Author:** ![flu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/flu/32/813_2.png) [@flu](https://forum.legato.io/u/flu)\
**Post date:** [January 22, 2018, 9:24am UTC](https://forum.legato.io/t/sandbox-python-app/2976/2 "2018-01-22T09:24:31Z")

</div>

Hello Gustavo,

It is required to list all the files that are required for a python calls from inside a sandbox.  
This list must be added to the \*.adef of \*.cdef file.  
This lists depends on the product you are using.

Example with a product different from FX30:  
requires: {  
file: {  
“/usr/bin/python”  
“/bin/”  
“/usr/bin/python2.7”  
“/bin/”  
“/usr/lib/libpython2.7.so.1.0”  
“/lib/”  
}  
}

Such list can be got by running this target tool:  
`# sbtrace <myApp>`  
see also [sbtrace - Legato Docs](http://legato.io/legato-docs/latest/toolsTarget_sbtrace.html)

Regards.

---

<div class="post-metadata">

**Author:** ![GustavoCarlos](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/gustavocarlos/32/295_2.png) [@GustavoCarlos](https://forum.legato.io/u/GustavoCarlos)\
**Post date:** [January 31, 2018, 12:09am UTC](https://forum.legato.io/t/sandbox-python-app/2976/3 "2018-01-31T00:09:11Z")

</div>

Hello flu,

Thank you for your suggestion, it has helped me to start find the missing files in my app.

I added the files that were requested by sbtrace in my requires section like this:

file:  
{  
/usr/bin/python /usr/bin/python  
/usr/lib/libpython2.7.so.1.0 /usr/lib/  
/lib/libutil.so.1 /lib/  
/proc/meminfo /proc/meminfo  
/usr/lib/libreadline.so.5 /usr/lib/  
/lib/libtinfo.so.5 /lib/  
/etc/terminfo /etc/terminfo  
}

Unfortunately I am having problem to start the app, when I follow the sbtrace and type Yes for modules, at the end even with an alert of internal error, the app status changes to “running”.

Do you have an idea of what I can do to solve this?

Thank you so much!

BR

Gustavo

---

<div class="post-metadata">

**Author:** ![flu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/flu/32/813_2.png) [@flu](https://forum.legato.io/u/flu)\
**Post date:** [January 31, 2018, 8:15am UTC](https://forum.legato.io/t/sandbox-python-app/2976/4 "2018-01-31T08:15:03Z")

</div>

Hello Gustao,

The Legato App might not work well after a sbtracing.  
I suggest doing this:

> sbtrace   
> app restart

Regards,  
flu.

---

<div class="post-metadata">

**Author:** ![GustavoCarlos](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/gustavocarlos/32/295_2.png) [@GustavoCarlos](https://forum.legato.io/u/GustavoCarlos)\
**Post date:** [February 1, 2018, 12:49am UTC](https://forum.legato.io/t/sandbox-python-app/2976/5 "2018-02-01T00:49:19Z")

</div>

Thanks flu,

I did that, and check the log of the board, what I get for the python process was this

Jan 6 00:32:42 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | proc.c proc\_Start() 1394 | Starting process ‘python’ with pid 2239  
Jan 6 00:32:42 fx30 user.info Legato: INFO | sbtrace[2238]/sbtrace T=main | sbtrace.c AttachHandler() 646 | Attaching to process 2239.  
Jan 6 00:32:42 fx30 user.info Legato: INFO | sbtrace[2238]/sbtrace T=main | sbtrace.c AttachHandler() 659 | Unblocking process 2239.  
Jan 6 00:32:42 fx30 user.info Legato: INFO | supervisor[2239]/supervisor T=main | proc.c proc\_Start() 1359 | Execing ‘python’  
Jan 6 00:32:47 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateDirLink() 1451 | Created directory link ‘/proc’ to ‘/legato/systems/current/appsWriteable/helloPython/proc’.  
Jan 6 00:32:49 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateFileLink() 1583 | Created file link ‘/usr/lib/libreadline.so.5’ to ‘/legato/systems/current/appsWriteable/helloPython/usr/lib/libreadline.so.5’.  
Jan 6 00:32:51 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c CreateFileLink() 1583 | Created file link ‘/lib/libtinfo.so.5’ to ‘/legato/systems/current/appsWriteable/helloPython/lib/libtinfo.so.5’.  
Jan 6 00:32:52 fx30 user.emerg Legato: _EMR_ | sbtrace[2238]/sbtrace T=main | sbtrace.c HandleSysCall() 1214 | Could not import file /etc/terminfo. LE\_NOT\_FOUND.  
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /proc from helloPython.  
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /usr/lib/libreadline.so.5 from helloPython.  
Jan 6 00:32:53 fx30 user.info Legato: INFO | supervisor[519]/supervisor T=main | app.c RemoveLinks() 2420 | Removing link /lib/libtinfo.so.5 from helloPython.

It looks like it can’t import terminfo, all this folders that are linked I must put in the .adef file isn’t it?

Thank you a lot

BR

Gustavo

---

<div class="post-metadata">

**Author:** ![flu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/flu/32/813_2.png) [@flu](https://forum.legato.io/u/flu)\
**Post date:** [February 1, 2018, 4:18pm UTC](https://forum.legato.io/t/sandbox-python-app/2976/6 "2018-02-01T16:18:51Z")

</div>

Hello Gustavo,

As terminfo is a folder, you should use this instead;

> requires: {  
> …  
> dir: {  
> …  
> “/etc/terminfo” “/etc/terminfo”  
> …  
> }  
> …

KR,  
flu.

---

<div class="post-metadata">

**Author:** ![GustavoCarlos](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/gustavocarlos/32/295_2.png) [@GustavoCarlos](https://forum.legato.io/u/GustavoCarlos)\
**Post date:** [February 28, 2018, 5:32pm UTC](https://forum.legato.io/t/sandbox-python-app/2976/7 "2018-02-28T17:32:16Z")

</div>

Hi Flu,

Thank you for the advices,

I had some progress by using the Developer Studio to compile the app, by now I could get to this message

=ERR= | python[9530] | ‘getpwuid(): uid not found: 1023’

According to the example, when I got this, it was suppose just to put the envVars section and it would work, but in my case it shows that python command was not recognized.

Is this the only way that I can put my application to run at startup of the board?

Thanks a lot

Best Regards

Gustavo

---

<div class="post-metadata">

**Author:** ![flu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/flu/32/813_2.png) [@flu](https://forum.legato.io/u/flu)\
**Post date:** [March 7, 2018, 2:14pm UTC](https://forum.legato.io/t/sandbox-python-app/2976/8 "2018-03-07T14:14:38Z")

</div>

Hello Gustavo,

Here is a working sandboxed Legato Application, that can call Py\_\* functions and runs a \*.py file (previoulsy bundled into the \*.update package)

KR,  
flu.

[LegatoPy.zip](https://forum.legato.io/uploads/short-url/bTc4cNtJgYYLOpwdPwO0K7WmJ7x.zip) (3.2 KB)
