Page 1 of 1

WM shell (Python)

PostPosted: September 11th, 2009, 11:13 am
by mariuszp
I am creating a DE (desktop environment) at the moment, and I have a big problem with the window manager.

I am creating this whole thing in Python, and the problem is quite complicated. I'm using Linux. Say I run the following code:

Code: Select all
from subprocess import *

p = Popen("python", shell="my-shell.py")


This works PERFECTLY, the "my-shell.py" script seems to run as the shell for "python", but the problem is, I don't know how to create my-shell.py to receive commands from "python" and send responses through e.g. stdout.

I guess that when the program calls os.popen(), the second object, "stdout" would be sys.stdout from the my-shell.py script. If i'm wrong, correct me. But how do you receive those command, and if the shell can't recognise them, how do you send them to the default "bash" and send the reply from bash to the program?

EDIT: another problem:

Code: Select all
from subprocess import *

p = Popen("python hello.py")


Even if "hello.py" exists, it gives an error, saying it can't find some file... Why is that?

Re: WM shell (Python)

PostPosted: September 12th, 2009, 4:58 am
by TrappedTime
Well I think I know what you're saying.
You can't make the other thing give the python the orders because yuo don't know how to make python recognize them.
I would say first program the orders into python first and then have the other one be able to present the orders.
Then python can take the orders and perform the actions givent with the order.

Correct me if I'm wrong, I haven't studied computer applications/errors.

*Though I do know HCC.*

Re: WM shell (Python)

PostPosted: September 19th, 2009, 9:04 am
by mariuszp
TheBetterGamer wrote:Well I think I know what you're saying.
You can't make the other thing give the python the orders because yuo don't know how to make python recognize them.
I would say first program the orders into python first and then have the other one be able to present the orders.
Then python can take the orders and perform the actions givent with the order.

Correct me if I'm wrong, I haven't studied computer applications/errors.

*Though I do know HCC.*


I already found a good solution. But anyway, I'll explain what problem I've had, so that you understand what I'm on about.

Basically, a SHELL is an application that provides access to some part of an operational system. Python's os.system() or os.popen() and simillar functions, write the requests to the shell's stdin, and read its stdout. Furthermore, a shell enables two processes to communicate. It's able to read/write from the process' stdin, stdout and stderr.