473,287 Members | 1,946 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,287 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 978

"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.
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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...

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.