Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29115
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.04; 'run- time': 0.05; 'file)': 0.07; 'python': 0.09; 'failed:': 0.09; 'guys.': 0.09; 'os.path': 0.09; 'received:mail- vc0-f174.google.com': 0.09; 'sep': 0.09; 'template.': 0.09; 'cc:addr:python-list': 0.10; 'subject:not': 0.11; 'static': 0.13; 'finished': 0.15; '64-bit,': 0.16; 'accordingly,': 0.16; 'command:': 0.16; 'iteration.': 0.16; 'output?': 0.16; 'presume': 0.16; 'python;': 0.16; 'subprocess': 0.16; 'wrote:': 0.17; 'exists': 0.17; 'pfxlen:0': 0.17; "shouldn't": 0.17; 'thu,': 0.17; 'thanks,': 0.18; 'variable': 0.20; 'changes': 0.20; 'import': 0.21; 'meant': 0.21; 'cheers,': 0.23; 'cc:2**0': 0.23; 'split': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'complete,': 0.29; 'prints': 0.29; 'received:209.85.220.174': 0.29; 'sleep': 0.29; 'that.': 0.30; 'normally': 0.30; 'figure': 0.30; 'stuff': 0.30; 'problem.': 0.32; 'file': 0.32; 'could': 0.32; '(with': 0.33; 'another': 0.33; 'program,': 0.34; 'received:google.com': 0.34; 'built-in': 0.35; 'moved': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'possible': 0.37; 'bad': 0.37; 'does': 0.37; 'uses': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'header:Received:5': 0.40; 'your': 0.60; "you'll": 0.62; 'between': 0.63; 'behavior': 0.64; 'therefore': 0.65; 'results': 0.65; 'as:': 0.75; 'difference.': 0.84; 'sender:addr:chris': 0.84; 'trickery': 0.84; 'try.': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=AQFetYFP2V6euzJkVq9Rkq4QvXlAbqHirFJooRJ55xY=; b=CN/k/MYpGJ5rOxDs54bB9gfdOgPDNSqLkx0cfoFdaI3tyD6+EBxd2uxcrvMB2XWXvi N1xUssHMHsEirlyuRLEVgWhwEWvThb4dqbYHLjePO2AzsH6i1gJ8m9km/T21nhpAEzvC 5iini51xmhfbV/J916JL2Xt3gescxoOhQeC10= |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=AQFetYFP2V6euzJkVq9Rkq4QvXlAbqHirFJooRJ55xY=; b=eB+wf9sA8AcoXyg1Uv4R2LuEu/lDpJToKuhJqwDJ/7Bg+XQdyR4TX52tbdnAzEmboj TE7Qb6mHVaXe2HZa0L98B3e6FBmQHgRjDrH8QaztynpxBMXf+qaaOvkX9LihjdUZtaAp 7hpHjrZlkw3N+5402TnrapM0GuvpAwDhpRPk5cnSgtfNTtdk0xbsW+waSlTgaMzDp0aw 2c06UfAbry93B7lZeEcM9u7Hlldkx+5Bpvs0/p3fDh8L2uh9mNpVWvxBQp0NMxI350t0 pxtsKUo8GPM/iMT7mXNfIQQqW+sNJQjTXrEXZ3JapoF55+oVt2R/npCjK77zXNHdFEmC fOwA== |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <a328f7cc-48e3-426d-bfd1-9c8893e1b701@googlegroups.com> |
| References | <746448155.528147.1347550469072.JavaMail.root@sequans.com> <mailman.616.1347551196.27098.python-list@python.org> <a328f7cc-48e3-426d-bfd1-9c8893e1b701@googlegroups.com> |
| Date | Thu, 13 Sep 2012 22:24:04 -0700 |
| X-Google-Sender-Auth | QGsCRJkL9Va6P1pw_fwBCpzHonQ |
| Subject | Re: subprocess call is not waiting. |
| From | Chris Rebert <clp2@rebertia.com> |
| To | paulstaten@gmail.com |
| Content-Type | text/plain; charset=UTF-8 |
| X-Gm-Message-State | ALoCoQmZLEzdqpfTbFIqmEA6iA5hbi32uEhfnSe6kZpd2+HgqHuVJXua/CGHv5mSmjno5uL623Ys |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.667.1347600247.27098.python-list@python.org> (permalink) |
| Lines | 60 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347600247 news.xs4all.nl 6944 [2001:888:2000:d::a6]:54913 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:29115 |
Show key headers only | View raw
On Thu, Sep 13, 2012 at 11:36 AM, <paulstaten@gmail.com> wrote:
> Thanks, guys.
> MRAB-RedHat 6 64-bit, Python 2.6.5
In your Unix shell, what does the command:
type htar
output?
> JM-Here's the relevant stuff from my last try.
If you could give a complete, self-contained example, it would assist
us in troubleshooting your problem.
> I've also tried with subprocess.call. Just now I tried shell=True, but it made no difference.
It's possible that htar uses some trickery to determine whether it's
being invoked from a terminal or by another program, and changes its
behavior accordingly, although I could not find any evidence of that
based on scanning its manpage.
> sticking a print(out) in there just prints a blank line in between each iteration. It's not until the 5 trials are finished that I am told: download failed, etc.
>
> from os.path import exists
> from subprocess import call
> from subprocess import Popen
> from shlex import split
> from time import sleep
>
> while (exists(file)==0) and (nTries < 5):
`file` is the name of a built-in type in Python; it should therefore
not be used as a variable name.
Also, one would normally write that as:
while not exists(file) and nTries < 5:
> a = Popen(split('htar -xvf ' + htarArgs), stdout=PIPE, stderr=PIPE)
What's the value of `htarArgs`? (with any sensitive parts anonymized)
Also, you really shouldn't use shlex.split() at run-time like that.
Unless `htarArgs` is already quoted/escaped, you'll get bad results
for many inputs. Use shlex.split() once at the interactive interpreter
to figure out the general form of the tokenization, then use the
static result in your program as a template.
> (out,err) = a.communicate()
> if exists(file)==0:
> nTries += 1
> sleep(0.5)
>
> if exists(file)==0: # now that the file should be moved
> print('download failed: ' + file)
> return 1
>
> I've also tried using shell=True with popopen.
I presume you meant Popen.
Cheers,
Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: subprocess call is not waiting. MRAB <python@mrabarnett.plus.com> - 2012-09-13 16:46 +0100
Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-13 11:36 -0700
Re: subprocess call is not waiting. Chris Rebert <clp2@rebertia.com> - 2012-09-13 22:24 -0700
Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-13 11:36 -0700
csiph-web