Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
151 user(s) are online (131 user(s) are browsing Forums)

Members: 1
Guests: 150

jabirulo, more...

Support us!

Headlines

 
  Register To Post  

subprocess module in Python?
Just can't stay away
Just can't stay away


See User information
Am I right to assume subprocess is not implemented in our Python?
This is the error I have:
File "PYTHON:Lib/subprocess.py", line 973, in _set_cloexec_flag
old = fcntl.fcntl(fd, fcntl.F_GETFD)
IOError: [Errno 78] Function not implemented

I wanted to run a command and wait for its completion. It seems os.system() can't do it so I tried subprocess.call() and I have the error above

Thanks

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: subprocess module in Python?
Home away from home
Home away from home


See User information
Yes you would be right. It does not work and can bot work with the public versions on python and support libraries.


Go to top
Re: subprocess module in Python?
Home away from home
Home away from home


See User information
What command did you want run?

os.system() *should* do that for you.

or if you need to get the output back there is a simple pipe.

filehandle = os.popen("command that outputs",'r')

output = filehandle.read()

filehandle.close()

or you can do it the other way

filehandle = os.popen("command that needs input",'w')

filehandle.write("some input")

filehandle.close()


You can't do it two way though that's what you need subprocess etc for.



Go to top
Re: subprocess module in Python?
Just can't stay away
Just can't stay away


See User information
I just want the execution paused until the command returns. I don't need any input or output.

I need to use it from within an "Installation Utility" installation script. If I use os.system, the script continues execution immediately. As the rest of the script depends on the completion of the AmigaDOS command (downloading a file with wget), I have to wait for its completion.

Or maybe I could try as suggested here i.e. doing the download from the Python script.

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: subprocess module in Python?
Home away from home
Home away from home


See User information
Quote:

I need to use it from within an "Installation Utility" installation script. If I use os.system, the script continues execution immediately. As the rest of the script depends on the completion of the AmigaDOS command (downloading a file with wget), I have to wait for its completion.


That's a bit odd, os.system() shouldn't return before the command has unless perhaps the command is detaching itself from the shell? How are you calling it?

For an experiment I did

os.system("wait 10") at the python prompt, it took 10 secs to return as expected.

os.system("WGET http://www.broad.ology.org.uk/")

also did not return before exit of WGET

However it would make a lot of sense to use the urllib urllib2 modules instead of an external command.


Go to top
Re: subprocess module in Python?
Just can't stay away
Just can't stay away


See User information
Oh yes you are right. I just tried running a script from shell.

So the culprit is "Installation Utility" which runs the Python script through PyRun_SimpleFile() (doc here).
Anyway, I'll try urllib.

Edit: well it's only half of the truth.
If I run the installation script below, the "wait 5" works as expected but "wait 10" doesn't.

import os
os.system("wait 5")

def downloadPage(page):
os.system("wait 10")
return True

---SNIP---

processingPage1 = NewPage(PROCESSING)
SetString(processingPage1, "message", "some text")
SetObject(processingPage1, "processor", downloadPage)

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: subprocess module in Python?
Home away from home
Home away from home


See User information
Quote:



Edit: well it's only half of the truth.
If I run the installation script below, the "wait 5" works as expected but "wait 10" doesn't.

import os
os.system("wait 5")

def downloadPage(page):
os.system("wait 10")
return True

---SNIP---

processingPage1 = NewPage(PROCESSING)
SetString(processingPage1, "message", "some text")
SetObject(processingPage1, "processor", downloadPage)


I'm not familiar with the Installation Utility, but clearly it's more than just a python interpreter, but rather an apliaction with python embeded (like blender in a way).

If you code snippet above does not wait for 10 seconds it suggest that the 'processor' is being called asynchronously, as os.system() surely will wait.

try adding som e timeing debug code.

import os
import time

def downloadPage(page):
print time.time()
os.system("wait 10")
print time.time()
return True


Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project