WM shell (Python)

Need programming help? Want to post programming tips? Are you programming a game and want to show it off? That and more here.

WM shell (Python)

Postby mariuszp » September 11th, 2009, 11:13 am

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?
mariuszp
Guardian to Glitch Castle

 
Posts: 11
Joined: September 8th, 2009, 8:53 am

Thumbs Up given: 0 times
Thumbs Up received: 0 times

Re: WM shell (Python)

Postby TrappedTime » September 12th, 2009, 4:58 am

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.*
Gregg Shorthand : http://gregg.angelfishy.net/
(Chapters on the right column)
TrappedTime
The Legacy

 
Posts: 777
Joined: August 6th, 2009, 7:58 pm

Thumbs Up given: 0 times
Thumbs Up received: 1 time

Re: WM shell (Python)

Postby mariuszp » September 19th, 2009, 9:04 am

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.
mariuszp
Guardian to Glitch Castle

 
Posts: 11
Joined: September 8th, 2009, 8:53 am

Thumbs Up given: 0 times
Thumbs Up received: 0 times


Return to Programming