Processes.

G

Guy

Hi

I've done some projects in python for my work which invole some test
scripts etc. All quite basic stuff, I find python a good language to
work in but have come up against a brick wall. I'm been searching
google for hours about processes pids etc. My problem is as follows
the main problem code can be seen below :

server = uc_server(HOST_str, PORT_num)
while 1:
asyncore.poll(SERVER_TIMEOUT)

# Only pops queue when the current item is blank.
if (server.current_queue_item == [0,"","",["",0],["",""]]):
# Pops a queue item if there are any queue items to get.
Temp_Current_Item = MainQueue.Pop()
if (Temp_Current_Item != N):
server.current_queue_item = Temp_Current_Item

Execute_Command_str =
ServerSupport.CreateCommand(Temp_Current_Item)

# Only executes if on a win32 platform.
if (sys.platform == "win32")and(Execute_Command_str != N):
output, input = popen2("cmd.exe")
input.write(Execute_Command_str+"\n")
input.write("exit\n")

while 1:
text = output.readline()
if text:
print text
else:
# Sets the current queue item to blank.
server.current_queue_item =
[0,"","",["",0],["",""]]
break

What I want to have is a server which is multi platform win32,
unix(lots of differnt sorts and may be mac later but forget mac for
now.) that people can telnet onto leave a job, and then the server
runs the jobs one at a time.
What I have is a server that people can telnet on to leave a job, the
server will execute it and keep executing it until it is done. I
thought that maybe the poll thing would sort this out by switching
from the main body of the script to the server part of the script, but
it didn't. The way that I use popen2 is my fav. way of executing
processes as I can catcher all output. What would be really good if I
could execute commands or scripts by using child processes and
searching for there pids this way I would know whats running on the
box at any one time.
There's loads about pids processes on google but it mainly in unix, I
mainly want it in win32 which there is hardly anything about.

Please Please Help

TIA
TTFN
Guy
 
T

Trent Mick

Guy,

Basically working with processes in a cross-platform manner is a pain.
:) Yes PIDs are more of a Linux/Unix thing. I think they do exist to a
degree on Windows but that would only be as part of Windows' weak posix
compliance layer. In Windows you generally want to talk about process
handles. However, Python's standard process handling stuff doesn't
generally expose the handles for started processes. I have a module
called process.py that might help do what you want to do. Give it a try:
http://starship.python.net/crew/tmick/#process

Cheers,
Trent


[Guy wrote]
Hi

I've done some projects in python for my work which invole some test
scripts etc. All quite basic stuff, I find python a good language to
work in but have come up against a brick wall. I'm been searching
google for hours about processes pids etc. My problem is as follows
the main problem code can be seen below :

server = uc_server(HOST_str, PORT_num)
while 1:
asyncore.poll(SERVER_TIMEOUT)

# Only pops queue when the current item is blank.
if (server.current_queue_item == [0,"","",["",0],["",""]]):
# Pops a queue item if there are any queue items to get.
Temp_Current_Item = MainQueue.Pop()
if (Temp_Current_Item != N):
server.current_queue_item = Temp_Current_Item

Execute_Command_str =
ServerSupport.CreateCommand(Temp_Current_Item)

# Only executes if on a win32 platform.
if (sys.platform == "win32")and(Execute_Command_str != N):
output, input = popen2("cmd.exe")
input.write(Execute_Command_str+"\n")
input.write("exit\n")

while 1:
text = output.readline()
if text:
print text
else:
# Sets the current queue item to blank.
server.current_queue_item =
[0,"","",["",0],["",""]]
break

What I want to have is a server which is multi platform win32,
unix(lots of differnt sorts and may be mac later but forget mac for
now.) that people can telnet onto leave a job, and then the server
runs the jobs one at a time.
What I have is a server that people can telnet on to leave a job, the
server will execute it and keep executing it until it is done. I
thought that maybe the poll thing would sort this out by switching
from the main body of the script to the server part of the script, but
it didn't. The way that I use popen2 is my fav. way of executing
processes as I can catcher all output. What would be really good if I
could execute commands or scripts by using child processes and
searching for there pids this way I would know whats running on the
box at any one time.
There's loads about pids processes on google but it mainly in unix, I
mainly want it in win32 which there is hardly anything about.

Please Please Help

TIA
TTFN
Guy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top