Properly handling prints and feedback when automatically executing a script

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Properly handling prints and feedback when automatically executing a script

Adam Preble
I have opted to have my C++ main call an autoexec.py script by default when compiled to support the interpreter.  Ultimately, I will want to run some Python code w/o user intervention to do it.  I have come up with this somewhat naive implementation:


It starts the script but isn't handling prints inside the script.  They just get completely suppressed.  How can I get them to come out to the console?

For this matter, this naive implementation just runs in a console.  I'd love to be able to embed a prettier UI element but it looks like I'd have to come up with a lot of code myself.  I'm trying to do this for a 3d project, so it would make some sense to have a console UI embedded in I could tilde into.  Ultimately, I'd want to be able to autoexec the script, while having this other console for similarly manipulating state--with appropriate concurrency controls.  Is there a known path for doing that kind of thing?  

The only place I really saw something like this happening at all was with Blender, and the code for doing that in particularly didn't just pop right out at me, and in the IRC channel I wasn't given any other hints than to look at the code.


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Properly handling prints and feedback when automatically executing a script

Jim Bosch-2
On 01/27/2012 06:43 PM, Adam Preble wrote:

> I have opted to have my C++ main call an autoexec.py script by default when
> compiled to support the interpreter.  Ultimately, I will want to run some
> Python code w/o user intervention to do it.  I have come up with this
> somewhat naive implementation:
>
> http://pastebin.com/NTytF6iQ
>
> It starts the script but isn't handling prints inside the script.  They
> just get completely suppressed.  How can I get them to come out to the
> console?
>

I think this is essentially a Python C-API problem that has nothing to
do with Boost.Python, so this probably isn't the best list to get help
on that question (the cplusplus-sig is perhaps a lot
Boost.Python-focused than the name would suggest).

> For this matter, this naive implementation just runs in a console.  I'd
> love to be able to embed a prettier UI element but it looks like I'd have
> to come up with a lot of code myself.  I'm trying to do this for a 3d
> project, so it would make some sense to have a console UI embedded in I
> could tilde into.  Ultimately, I'd want to be able to autoexec the script,
> while having this other console for similarly manipulating state--with
> appropriate concurrency controls.  Is there a known path for doing that
> kind of thing?
>
> The only place I really saw something like this happening at all was with
> Blender, and the code for doing that in particularly didn't just pop right
> out at me, and in the IRC channel I wasn't given any other hints than to
> look at the code.
>

It sounds to me like you're trying to do something very complex...to the
extent that looking at the Blender code may not be a terrible starting
point, even if you do have to wade through a lot of unrelated code.  In
any case, I very much doubt you'll find a packaged solution or even much
in the way of examples that do all of the above without being part of a
larger system.

Sorry I couldn't be more helpful.

Jim
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig