Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103616
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ganesh Pal <ganesh1pal@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: list index out of range Error , need to fix it or ignore it |
| Date | Sun, 28 Feb 2016 14:00:14 +0530 |
| Lines | 87 |
| Message-ID | <mailman.1.1456648634.9760.python-list@python.org> (permalink) |
| References | <CACT3xuU5L9+EbJcw+L7vySKnYO83MQQ3M4zkMLz2G85dWrBT=g@mail.gmail.com> <CACT3xuWKjiiLWRW1v+e+ySwqM7g-CiZKRD3dy2hhK4XQTzaRHA@mail.gmail.com> <CAPM-O+wMX2ibRvy8yWAGR+EMxDcstF8mLTkptWOKrVb9_ys09Q@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de N2OZp/FV/ACqZW+PbdiSGwXUB1ZLIj69DO1TDJqUlkYQ== |
| Return-Path | <ganesh1pal@gmail.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; '"""': 0.05; '__name__': 0.07; 'filename': 0.07; 'main()': 0.07; 'skip:/ 10': 0.07; 'subject:Error': 0.07; 'wrapper': 0.07; 'cc:addr:python-list': 0.09; 'cmd': 0.09; 'exited': 0.09; 'func': 0.09; 'lines:': 0.09; 'stdout': 0.09; 'subject:ignore': 0.09; 'python': 0.10; 'exception': 0.13; 'index': 0.13; 'def': 0.13; "'__main__':": 0.16; 'main():': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:need': 0.18; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'machine': 0.21; 'ok.': 0.22; 'header:In-Reply-To:1': 0.24; 'subject:list': 0.26; 'command': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'idea': 0.28; 'print': 0.30; 'run': 0.33; 'extract': 0.33; 'traceback': 0.33; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'machines': 0.35; 'expected': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'your': 0.60; 'back': 0.62; 'dont': 0.64 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=KWdZ5s9pq2KLuSitApfuP0fZAcDCzkJxwZlh17QxEIM=; b=hX5cjkJSMlK5USD+0LZR9OsIxFPWEP1Arp3klkkSnW5adMqMmbslDNtccTtdj4OWaA PcPN5Z18BISqn7gPNM1Dn6hFfS6o5QyK/EOq1OsMIkUSsKv6xRuWB28yYfs0HYlx087c I0MXSwfWefmlpwUbnmoL6kXcqP3LN9HPyRRVRTjzeHKZh71Iq5I+JIjUQLn3IgzuvLVp aoOFtpdSVTt6PG/ZyF55x/nSD3aDnjFGeF3bysawHv8xWmmlN4pF85yEUDrm1kPWHTcp JLxR2oLV5uMNhjQ66S0ZiVQPiF0JxcFJMXl1TFYkBME7DvXx+/1XuY834URJHhBaapA4 SfJw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=KWdZ5s9pq2KLuSitApfuP0fZAcDCzkJxwZlh17QxEIM=; b=f0fMBiKNICDAcHtPTjAE7gU2NJcIb6wtQFltTLqVXFqwZ4s/TL76fMsvRmKnne93f9 GgaBtY0X3LkCnZQrP8Sg/LTEeddebWJbfOXc7AOiIGqdndHgheQKFAiDuxjitqYJ8ZqN U5B3/yEjjlV+uLLK4d+xkWvKKx1Su74L2lb2buVLAJflGvcOnfrT8uZarPC/3P6Bf/2U DZ+R4pB5b3mJnbVPNc2FLEgQkLTuIWsIDbXmEhxDFu+Sw0bhOiyIifRqFEskRGwgKRBA AfddihpbJboTCPSgEg5foBQ3YYlcyFtKyge/kgKUpxCB1/3egyk/P1KIEfc53jKXTWsa 2a/w== |
| X-Gm-Message-State | AD7BkJJ69aNqPZQqWYpMQJGu+MkJDQ1El4IK20wu6SegzfD2TKdzkS22J6feIbOuI7WUrfCGancsIFFIePYUOQ== |
| X-Received | by 10.112.54.201 with SMTP id l9mr3536164lbp.105.1456648214657; Sun, 28 Feb 2016 00:30:14 -0800 (PST) |
| In-Reply-To | <CAPM-O+wMX2ibRvy8yWAGR+EMxDcstF8mLTkptWOKrVb9_ys09Q@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103616 |
Show key headers only | View raw
>>
> what is run(...)
>
The run (_ is a wrapper it uses suprocess.Popen and returns stdout
,error and extitcod e
> not a good idea to have catchall exception
how to fix this ?
>
>> > return False
>> > if __name__ == '__main__':
>> > main()
>> >
>> --
>>
> copy and paste your traceback
>
I get " ERROR:root:list index out of range" error if the file is
not found in any of the machine , I dont have a trackback back
def check_file():
"""
333333333333333333333333333333333333333333333333333333333333333333333333333333333333
Run the command parallel on all the machines , if there is a
file named /tmp/file2.txt extract file2.txt
"""
global filename
file = ''
cmd = ("run_al_paral 'ls -al %s'" % (filename))
print(cmd)
stdout, stderr, exitcode = run(cmd)
print(stdout)
lines = stdout.strip().split('\n')
print(lines)
for line in lines:
if 'exited' in lines:
continue
file = lines[0].split()[9][6:]
break
print file
return file
def main():
functions = [check_file]
for func in functions:
try:
func()
except Exception as e:
return False
if __name__ == '__main__':
main()
1. But if the file is not present we get index out of range error , do
we need to fix this or its expected ? or its ok.
machine-4# python c_4.py
isi_for_array 'ls -al /tmp2/2.txt'
machine-2 exited with status 1
machine-1 exited with status 1
machine-4 exited with status 1
machine-5 exited with status 1
machine-3 exited with status 1
['machine-2 exited with status 1', 'machine-1 exited with status 1',
'machine-4 exited with status 1', 'machine-5 exited with status 1',
'machine-3 exited with status 1']
ERROR:root:list index out of range
3. Any other tips to improve the program
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: list index out of range Error , need to fix it or ignore it Ganesh Pal <ganesh1pal@gmail.com> - 2016-02-28 14:00 +0530
csiph-web