Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.freenet.ag!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: Re: list index out of range Error , need to fix it or ignore it Date: Sat, 27 Feb 2016 22:31:57 +0530 Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de DDDY7ABvY8SUsvj9LXT7xgiz9wn1cks0aLsetoIimFRg== Return-Path: 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; 'cmd': 0.09; 'func': 0.09; 'lines:': 0.09; 'subject:ignore': 0.09; 'exception': 0.13; 'def': 0.13; "'__main__':": 0.16; 'main():': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'typo': 0.16; 'subject:need': 0.18; 'try:': 0.18; 'to:name:python-list@python.org': 0.20; 'header:In- Reply-To:1': 0.24; 'example': 0.26; 'subject:list': 0.26; 'command': 0.26; 'message-id:@mail.gmail.com': 0.27; 'print': 0.30; 'run': 0.33; 'changed': 0.33; 'extract': 0.33; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'machines': 0.35; 'there': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40 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; bh=2f+YYGTg7An8trmbgcbYYg6rC9eEu5S5GQ8v8L1BJJ8=; b=S8zqYCaaZ5HW4zW+9H+Ek6tjKllMGtyp9BORCh0/UQ6/aXKEWIyzZC40sPJQfF2Lcc iLvDG9xBeZWmddK45To67jI2jl/5Ds3H0QZXr4WhotLvuO5O4Ams8M2ox3oCCU+Kkcz0 mlpE2rYWE0RTpJnQDE46LyURFDaadiRlxtI8ZwYDpcy6eVfE94lXSyFZEYFSA+T/6lZz z4FExuKhHRgS+ryIympXQdQeRXUj6GQwmjvbt0UOKrbQxNvVR0MRJOFRNTBhLahCC2DM S2V1jEIzWq3Ts8xIyndYkm8PzXPR7mTqbVPaviRboCGe2sZUoVkY0zMJQQO93Tl+5wQb btPg== 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; bh=2f+YYGTg7An8trmbgcbYYg6rC9eEu5S5GQ8v8L1BJJ8=; b=QKkErEvYf0md/FFviw0e8dBGIODeB9T9sdY9FuN7F3PjJ0tsE33MZPEz5FhAHTqGw0 /NTcMjsb9zgL152BHSYCONDuryYdVGhbJDb2T/zDUpwsVC4jTr0atUE8f4Uj0Kw90hFz afNm5p0uf6UDDoz7Lu4DrCtNEfbQf1B9Ps+6RBqnErXM2+In8N/hhFQUHa3qEiBZRhPX 8ld4GS60l32JRyXjTqaV7W2S0E+GLMRhWBperqo93MpNuuil6Bt3le5k5JzChHP4D9f2 /bsm6L5UPddG3xTjFMjiTB5wkbzMv2uYVLOJj3Sq3aZO3Zfmf8gEdSP2se8axv06epQQ 19bg== X-Gm-Message-State: AD7BkJL9GYfqM5Nyk3yWP4OA1sSUCoVe9uYn+5E64UZIdfq1zpP2688Hj5fQkgeSGzDUMYcVkUbLW8e8UdjUUg== X-Received: by 10.112.54.201 with SMTP id l9mr2677889lbp.105.1456592517156; Sat, 27 Feb 2016 09:01:57 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103593 changed baddr="" to file ="" in the example program , sorry for the typo > filename='/tmp2/2.txt' > > def check_file(): > """ > 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() >