473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

real time updating of subprocess.Popen()

Hii I am new to python and I would like to know how to update the output using the subprocess.Popen() process. My problem is similar to real time updating of popen, bufsize=0 problems ... but the only variation is that, I would like to get the print statements from the python file like...
Ex:
File_Name.py
Expand|Select|Wrap|Line Numbers
  1. i=0
  2. while i <= 1000 :
  3.   time.sleep(1)
  4.   print "waiting for 1 second for the %s time"%i
  5.   i=i+1
  6.  
cmd ='python File_Name.py" '
I have a python script which has this piece of code and would like to print it when i execute this file using:
ret = subprocess.Popen(cmd,bufsize=0,stdout=subprocess.P IPE, shell = True )
Expand|Select|Wrap|Line Numbers
  1. while True :
  2.   line = OP.stdout.readline()
  3.   if not line: break
  4.   print line
  5.  
print "End of print statements..."

I am unable to get the output of the script while running the script. (The whole data is being shown at once at the end of theexecution). Is there anyway to handle this situation..I tried the solution that has been referred earlier, but it works only for batch file not for script... :-(

Thanks in advance,

DecDon
Feb 8 '12 #1
1 2304
dwblas
626 Expert 512MB
There are wrappers around subprocess that may make your life easier. I haven't used them so can not say.

See "Foreground Processes"
https://github.com/amoffat/pbs/blob/master/README.md

Envoy
https://github.com/kennethreitz/envoy/
Feb 10 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time...
5
by: Beorne | last post by:
Hello, I'm a Java programmer and I'm new to C# (I've read something but I've no real programming experience). I'm programming a form that displays some data from an external source (i.e. a com...
13
by: bayer.justin | last post by:
Hi, I am trying to communicate with a subprocess via the subprocess module. Consider the following example: <subprocess.Popen object at 0x729f0> Here hey is immediately print to stdout of...
4
by: KPOJonesECC | last post by:
Hello, I am in the middle of an access database projet but are struggerling with a couple of things. I dont expect anyone to solve the problem for me, but would really appreciate a pointer in the...
4
by: =?iso-8859-1?B?aWFuYXLp?= | last post by:
hey all, I'm trying to get real time updates of batch file output. Here is my batch file: @echo off echo 1 @ping 127.0.0.1 -n 2 -w 1500 nul echo 2 @ping 127.0.0.1 -n 2 -w 1500 nul echo 3
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
1
by: Mrown | last post by:
Hi, I'm currently writing a python program that relies on a CLI program. What I'm currently doing is using subprocess.Popen on Python 2.5.1. Here's the line that I'm currently running: child...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.