Hi there!
I'm trying to convert a video in a background process.
The scenario I'm after:
1. The user uploads a video
2. The video is saved in my media directory, and the database is
populated with the references
3. The video gets converted to FLV - but the user shouldn't have to
wait around for this to happen
So, I thought to myself that spawnv would be a good fit for this. The
problem is that it doesn't fire of the command.
Here's my test script: http://dpaste.com/hold/7981/
Why won't this work? The while-loop is printed, but the os command
isn't executed. I've also tried to specify the whole path to mencoder
(/opt/local/bin/mencoder), but to no use. 8 1975
On Apr 5, 4:19 pm, "Henrik Lied" <henrikl...@gma il.comwrote:
Hi there!
I'm trying to convert a video in a background process.
The scenario I'm after:
1. The user uploads a video
2. The video is saved in my media directory, and the database is
populated with the references
3. The video gets converted to FLV - but the user shouldn't have to
wait around for this to happen
So, I thought to myself that spawnv would be a good fit for this. The
problem is that it doesn't fire of the command.
Here's my test script:http://dpaste.com/hold/7981/
Why won't this work? The while-loop is printed, but the os command
isn't executed. I've also tried to specify the whole path to mencoder
(/opt/local/bin/mencoder), but to no use.
I don't know what the deal is. Maybe you should try the subprocess
module since it replaces the os.spawn* modules and do a
subprocess.Pope n instead? Or don't assign the result to a variable
since you told it not to wait. You may need to do a combination of the
subprocess module and one of the Threading modules.
Mike
On Apr 5, 11:33 pm, kyoso...@gmail. com wrote:
On Apr 5, 4:19 pm, "Henrik Lied" <henrikl...@gma il.comwrote:
Hi there!
I'm trying to convert a video in a background process.
The scenario I'm after:
1. The user uploads a video
2. The video is saved in my media directory, and the database is
populated with the references
3. The video gets converted to FLV - but the user shouldn't have to
wait around for this to happen
So, I thought to myself that spawnv would be a good fit for this. The
problem is that it doesn't fire of the command.
Here's my test script:http://dpaste.com/hold/7981/
Why won't this work? The while-loop is printed, but the os command
isn't executed. I've also tried to specify the whole path to mencoder
(/opt/local/bin/mencoder), but to no use.
I don't know what the deal is. Maybe you should try the subprocess
module since it replaces the os.spawn* modules and do a
subprocess.Pope n instead? Or don't assign the result to a variable
since you told it not to wait. You may need to do a combination of the
subprocess module and one of the Threading modules.
Mike
Thanks for the quick reply, Mike!
I've taken a look at the Subprocess module, but it's all a bit new to
me, if you know what I mean.
You wouldn't be able to supply me with an example, would you?
Thanks!
En Thu, 05 Apr 2007 18:19:56 -0300, Henrik Lied <he********@gma il.com>
escribió:
So, I thought to myself that spawnv would be a good fit for this. The
problem is that it doesn't fire of the command.
Here's my test script: http://dpaste.com/hold/7981/
Why won't this work? The while-loop is printed, but the os command
isn't executed. I've also tried to specify the whole path to mencoder
(/opt/local/bin/mencoder), but to no use.
You are using:
v = os.spawnv(os.P_ NOWAIT, "mencoder", "/Users/henriklied/test.mov
-ofps 25 -o test.flv ...")
Read the docs about the spawnv function: http://docs.python.org/lib/os-process.html#l2h-2749
In particular "...The "v" variants are good when the number of parameters
is variable, with the arguments being passed in a list or tuple as the
args parameter. In either case, the arguments to the child process must
start with the name of the command being run."
So, for spawnv, you should build a list with each argument as an item,
being "mencoder" the first item.
But in your case it's a lot easier to use spawnl:
v = os.spawnl(os.P_ NOWAIT, "mencoder", "mencoder",
"/Users/henriklied/test.mov", "-ofps", "25", "-o", "...")
--
Gabriel Genellina
On Apr 5, 11:39 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
En Thu, 05 Apr 2007 18:19:56 -0300, Henrik Lied <henrikl...@gma il.com>
escribió:
So, I thought to myself that spawnv would be a good fit for this. The
problem is that it doesn't fire of the command.
Here's my test script:http://dpaste.com/hold/7981/
Why won't this work? The while-loop is printed, but the os command
isn't executed. I've also tried to specify the whole path to mencoder
(/opt/local/bin/mencoder), but to no use.
You are using:
v = os.spawnv(os.P_ NOWAIT, "mencoder", "/Users/henriklied/test.mov
-ofps 25 -o test.flv ...")
Read the docs about the spawnv function: http://docs.python.org/lib/os-process.html#l2h-2749
In particular "...The "v" variants are good when the number of parameters
is variable, with the arguments being passed in a list or tuple as the
args parameter. In either case, the arguments to the child process must
start with the name of the command being run."
So, for spawnv, you should build a list with each argument as an item,
being "mencoder" the first item.
But in your case it's a lot easier to use spawnl:
v = os.spawnl(os.P_ NOWAIT, "mencoder", "mencoder",
"/Users/henriklied/test.mov", "-ofps", "25", "-o", "...")
--
Gabriel Genellina
Hi Gabriel,
Thanks for your reply - but I'm afraid to tell you that spawnl didn't
do the trick either.
Here's the full command I used: http://dpaste.com/hold/7982/
I'd still love to get a working example of my problem using the
Subprocess module. :-)
En Thu, 05 Apr 2007 18:53:04 -0300, Henrik Lied <he********@gma il.com>
escribió:
On Apr 5, 11:39 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
> v = os.spawnl(os.P_ NOWAIT, "mencoder", "mencoder", "/Users/henriklied/test.mov", "-ofps", "25", "-o", "...")
Thanks for your reply - but I'm afraid to tell you that spawnl didn't
do the trick either.
Here's the full command I used: http://dpaste.com/hold/7982/
What means "didnt do the trick"? Do you get an exception? what's the
returned value?
Does the command work OK from the console?
Try from the python interpreter, using P_WAIT, and inspect the returned
value.
I'd still love to get a working example of my problem using the
Subprocess module. :-)
The same thing:
p = subprocess.Pope n(["mencoder", "/users/...", "-ofps", ...])
--
Gabriel Genellina
On Apr 6, 12:09 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
En Thu, 05 Apr 2007 18:53:04 -0300, Henrik Lied <henrikl...@gma il.com>
escribió:
On Apr 5, 11:39 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
v = os.spawnl(os.P_ NOWAIT, "mencoder", "mencoder",
"/Users/henriklied/test.mov", "-ofps", "25", "-o", "...")
Thanks for your reply - but I'm afraid to tell you that spawnl didn't
do the trick either.
Here's the full command I used:http://dpaste.com/hold/7982/
What means "didnt do the trick"? Do you get an exception? what's the
returned value?
Does the command work OK from the console?
Try from the python interpreter, using P_WAIT, and inspect the returned
value.
That's what I've done. P_WAIT returned a the PID 127 - but there's
still no sign of the FLV-file, I'm afraid.
>
I'd still love to get a working example of my problem using the
Subprocess module. :-)
The same thing:
p = subprocess.Pope n(["mencoder", "/users/...", "-ofps", ...])
That example looked great at first, but on a closer look it didn't
quite end up to be what I wanted. In a real environment the user still
had to wait for the command to finish.
--
Gabriel Genellina
I'm not sure what to do. I'm thinking of simply creating a crontab
which checks the database every five minutes or so, and converts the
videos that aren't converted.
But if anyone has a good and easy solution in Python, I'd rather have
that. I dare to think that people here will understand that.
Henrik Lied wrote:
Does the command work OK from the console?
Try from the python interpreter, using P_WAIT, and inspect the returned
value.
That's what I've done. P_WAIT returned a the PID 127 - but there's
still no sign of the FLV-file, I'm afraid.
This does not look like a Python issue then; you'll have to find the
problem elsewhere. Perhaps the spawned process is blocked waiting for
user input, by example?
--
Gabriel Genellina
On Apr 5, 3:25 pm, "Henrik Lied" <henrikl...@gma il.comwrote:
I'd still love to get a working example of my problem using the
Subprocess module. :-)
The same thing:
p = subprocess.Pope n(["mencoder", "/users/...", "-ofps", ...])
That example looked great at first, but on a closer look it didn't
quite end up to be what I wanted. In a real environment the user still
had to wait for the command to finish.
Then you are not using it correctly. subprocess.Pope n() returns
immediately. Notice the order of events here:
In [2]: subprocess.Pope n('sleep 2; echo foo', shell=True); print
'bar'
bar
foo
-Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nushin |
last post by:
Greetings,
I am running RedHat 7.3 and trying to spawn a hello.py program from
hello_driver.py by using spawn*( ) API, as a P_NOWAIT :
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python hello.py >/dev/null
&'))
and when i check the process state code of hello.py by:
ps -aux
|
by: nushin |
last post by:
Try to launch a test program that prints hello world for a minute or
so using, spawnv( ) or spawnl( ). Check to see the process state code
that the program is running. I am using RedHat Linux 7.3 and Python
2.2.2 and i see that the program is either launched as Zombie state
using spawnv(), or running in State "S" sleep in spawnl( ).
Here's the sample code that launches my program:
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python...
|
by: nushin |
last post by:
If you do not null out the output of your parent process that launches
a child process by os.spawnv( ) in P_NOWAIT mode, you will see that
your child process is launched *synchronously* instead of
asynchronously. This is a bug!
Here's a code sample:
In your parent.py file, call child.py as
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python', 'child.py'))
|
by: Florian Lindner |
last post by:
Hello,
I want to compile that small python script:
bastet:/ # cat test.py
#!/usr/bin/python
import sys, os
username = os.getlogin()
print username
os.spawnv(os.P_WAIT, "/root/mailboxmgm.py", sys.argv)
|
by: alexLIGO |
last post by:
Hi,
I am trying to run a python script that executes several other programs
on the bash (under linux) and reads some of the output of those
programs. This works fine for a couple of os.system() calls, but then
it does not work anymore. os.system() returns always -1, but when
executing exactly the same program directly on the linux-bash it works!
Could this be a memory problem? It happens when there is much data
stored in a python...
| |
by: IamIan |
last post by:
I've had to migrate back to Python 2.1 and am now trying to use
os.spawnv to get around a memory leak (either in Python or ArcGIS or
both) in a geoprocessing script.
This script (Second Script) gets each Ascii file in the workspace,
converts it to a raster, sets the spatial reference, and hillshades it.
The script works on its own. In the Main Script I can successfully pass
parameters in a list, but no geoprocessing is ever initiated...
|
by: IamIan |
last post by:
I am using os.spawnv in Python 2.1 to do some geoprocessing in a
subroutine/process. Everything works great, except when the processing
is done the subroutine just waits for a couple minutes before closing
itself and returning to the main script. I have tried using sys.exit()
and exit() but these aren't doing anything.
What is the proper way to terminate this subroutine upon completion,
rather than waiting? Thank you.
|
by: Chris Reuter |
last post by:
I've been trying to start a particular external program from Python
using os.spawnv(). This works perfectly under Linux but under
Windows, it first runs the program, then throws an OSError exception
with the tuple (0, 'Error'):
>>> spawnv(P_WAIT, 'c:/mctools/bin/mc', )
Archelon Tool Driver 3.09 2005/02/16
No input file was given.
Traceback (most recent call last):
|
by: Fabio Chelly |
last post by:
Hi,
I have a command line that works fine when I execute it directly:
c:\\curl.exe -T c:\\upload.txt -u login:pwd ftp://ftp-myurl --ftp-ssl
But when I try to use os.spawnv to excute it from my python code, it
doesn't work at all. Here is my code:
exe = "c:\\curl.exe"
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |