From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: Antoine Pelisse <apelisse@gmail.com>,
Chris Rorvick <chris@rorvick.com>, Eric Raymond <esr@thyrsus.com>,
git <git@vger.kernel.org>
Subject: Re: [PATCH] Replace git-cvsimport with a rewrite that fixes major bugs.
Date: Thu, 03 Jan 2013 17:24:18 +0100 [thread overview]
Message-ID: <50E5B0B2.7060205@alum.mit.edu> (raw)
In-Reply-To: <7vip7expd8.fsf@alter.siamese.dyndns.org>
On 01/03/2013 04:22 PM, Junio C Hamano wrote:
> Antoine Pelisse <apelisse@gmail.com> writes:
>
>>> Doesn't Python come with a standard subprocess module that lets you
>>> spawn external programs safely, similar to the way Perl's list form
>>> open(), e.g. "open($fh, "-|", 'git', @args)", works?
>
> ... and of course a more boring "system('git', $subcmd, @args)", as well.
Python's os.system() takes exactly one argument, which must be a string,
and executes it in a subshell. subprocess is indeed the way to go.
>> You mean something like this:
>>
>> p1 = subprocess.Popen([backend.command()], stdout=subprocess.PIPE)
>> subprocess.Popen(["git", "fast-import", "--quiet"] + gitopts,
>> cwd=outdir, stdin=p1.stdout)
>>
>> Assuming gitopts is a list rather than a string. (care must be taken
>> with backend.command() also)
>
> Yes.
>
> I vaguely recall that the subprocess module once used to be one
> portability issue but that was between Python 2.3 and 2.4 or some
> ancient history, and it should no longer be relevant.
subprocess was added in Python 2.4, and the above example should work
fine in any version >= 2.4. But please note that other functions have
been added to the module since then, like check_call() (v2.5),
check_output (v2.7), and some methods were added to the Popen object in
v2.6.
Such things are documented pretty reliably in the Python library
documentation [1]; when in doubt, one can view older versions of the
library documentation, which are all available online [2].
Michael
[1] http://docs.python.org/2/library/
[2] http://www.python.org/doc/versions/
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
prev parent reply other threads:[~2013-01-03 16:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-01 17:26 [PATCH] Replace git-cvsimport with a rewrite that fixes major bugs Eric S. Raymond
2013-01-01 21:54 ` Junio C Hamano
2013-01-02 0:33 ` Eric S. Raymond
2013-01-02 1:06 ` Junio C Hamano
2013-01-02 8:02 ` Jonathan Nieder
2013-01-02 10:59 ` Eric S. Raymond
2013-01-02 15:39 ` Jonathan Nieder
2013-01-02 16:18 ` Eric S. Raymond
2013-01-02 16:32 ` Martin Langhoff
2013-01-02 16:41 ` Eric S. Raymond
2013-01-02 16:48 ` Thomas Berg
2013-01-02 21:15 ` Martin Langhoff
2013-01-02 22:28 ` Eric S. Raymond
2013-01-02 23:44 ` Martin Langhoff
2013-01-02 16:35 ` Jonathan Nieder
2013-01-02 16:43 ` Andreas Schwab
2013-01-02 18:08 ` Junio C Hamano
2013-01-02 18:37 ` Eric S. Raymond
2013-01-02 19:07 ` Junio C Hamano
2013-01-03 6:34 ` Chris Rorvick
2013-01-03 7:08 ` Junio C Hamano
2013-01-03 7:47 ` Antoine Pelisse
2013-01-03 15:22 ` Junio C Hamano
2013-01-03 16:24 ` Michael Haggerty [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50E5B0B2.7060205@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=apelisse@gmail.com \
--cc=chris@rorvick.com \
--cc=esr@thyrsus.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).