473,396 Members | 2,014 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,396 software developers and data experts.

subprocess - please enhance the documentation

Hi,

I'd like to suggest to add a few lines to chapter 17.1.3.5 "Replacing os.popen"
(Python Doc 2.5.2)

I have used the following code in the past

ARC='MyDumpFile'
tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
.....
tar_exit_code= tar_inp.close()
if tar_exit_code != None and tar_exit_code % 256 :
print "some error messages"

When replacing this - as suggested - by

TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
tar_inp= TAR.stdin
.....
tar_inp.close() always returns None.

So I have replaced this by

tar_inp.close()
tar_exit_code= TAR.wait()

if tar_exit_code != 0 :
print "some error messages"
Perhaps a few lines telling about this would be helpful.

Thanks,
Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jun 27 '08 #1
1 980

"Helmut Jarausch" <ja******@igpm.rwth-aachen.dewrote in message
news:69*************@mid.dfncis.de...
| Hi,
|
| I'd like to suggest to add a few lines to chapter 17.1.3.5 "Replacing
os.popen"
| (Python Doc 2.5.2)

1. Take a look at the existing 2.6 manual (on Python.org) to make sure it
has not already been improved. If not..

2. Post your suggestions on bugs.python.org and mark the item as
documentation and stdlib. Suggest the specific addition or change you
would like to see. If accepted, one of the doc-masters with add it with
the needed formatting code and possibly stylistic changes.

| I have used the following code in the past
|
| ARC='MyDumpFile'
| tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
| ....
| tar_exit_code= tar_inp.close()
| if tar_exit_code != None and tar_exit_code % 256 :
| print "some error messages"
|
| When replacing this - as suggested - by
|
| TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
| tar_inp= TAR.stdin
| ....
| tar_inp.close() always returns None.
|
| So I have replaced this by
|
| tar_inp.close()
| tar_exit_code= TAR.wait()
|
| if tar_exit_code != 0 :
| print "some error messages"
|
|
| Perhaps a few lines telling about this would be helpful.
|
| Thanks,
| Helmut.
|
| --
| Helmut Jarausch
|
| Lehrstuhl fuer Numerische Mathematik
| RWTH - Aachen University
| D 52056 Aachen, Germany
| --
| http://mail.python.org/mailman/listinfo/python-list
|

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dr. Who | last post by:
I am using the subprocess module in 2.4. Here's the fragment: bufcaller.py: import sys, subprocess proc = subprocess.Popen('python bufcallee.py', bufsize=0, shell=True, stdout=subprocess.PIPE)...
3
by: rh0dium | last post by:
Hi all, Here I was happily coming to working thinking - OK I need to create a wrapper for a tool (UNIX) which does nothing but lauch the end tool and send a sql instert letting the db know the...
3
by: Tom Plunket | last post by:
I'm using subprocess to launch, well, sub-processes, but now I'm stumbling due to blocking I/O. Is there a way for me to know that there's data on a pipe, and possibly how much data is there so...
2
by: smitty1e | last post by:
The first print statement does what you'd expect. The second print statement has rather a lot of rat in it. The goal here is to write a function that will return the man page for some command...
3
by: mclaugb | last post by:
Hello ALl, I have a compiled program "conv.exe" that works as follows: ----------------------------- Please selection from the following options. press "h" for help, "p" for print, "r" for...
23
by: Harishankar | last post by:
Hi, Sorry to start off on a negative note in the list, but I feel that the Python subprocess module is sorely deficient because it lacks a mechanism to: 1. Create non-blocking pipes which can...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
3
by: Jeremy Sanders | last post by:
Hi - I have some code which works under linux. It starts a remote python process using subprocess and communicates to it via a pipe created by os.pipe. As far as I understand, child processes...
5
by: thedsadude | last post by:
Hello, I'm launching a script as follows: <code> p = subprocess.Popen() p.wait() </code> If p.py writes to sys.stdout, then it is shown on the console.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.