Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'list?': 0.07; "'no": 0.09; 'stderr': 0.09; 'stdout': 0.09; 'def': 0.10; 'subject:error': 0.11; 'index': 0.13; 'dec': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function?': 0.16; 'indexerror:': 0.16; 'iterable,': 0.16; 'skip:" 70': 0.16; 'true:': 0.16; 'tuple,': 0.16; 'wrote:': 0.17; 'supposed': 0.21; 'number)': 0.22; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; '(most': 0.27; 'am,': 0.27; '(as': 0.27; 'message- id:@mail.gmail.com': 0.27; 'end,': 0.29; 'routine': 0.29; "i'm": 0.29; 'returned': 0.30; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'received:209.85.160.46': 0.32; 'skip:s 30': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; '(with': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'false': 0.35; 'returning': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'but': 0.36; 'possible': 0.37; 'does': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'range': 0.60; 'further': 0.61; 'different': 0.63; 'below:': 0.71; 'route': 0.84 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 :content-type; bh=TBSzuKZ0VhFTv/ySF5RtBTicnZcYVBlMpD+XjOYSIiM=; b=lCijGf8pza0dqBerGShoCQeImXbC47lEtb2MltLtPfi72xz6U83djN6rqHYs5CZqEF O2SeTAB8K2JTU/ST0ejWuECn/4k3nodDW2xQ2fT+ClgDbkPIJ6T4SxcTXs/MokEPwndi /6oU5Rlhanct+Qua6luko3/8yZnwsoOf7pcQZOPhb5U7h6TY5RK5E5aeV06S2AE4h1I8 iuYUNjeey1vDZE8b7S9vEKPxtgK07raKb6BOQ8JbxbhvSSbB+j5AYwmemw66tdYdSHob TmJTYiFGrt8hC5YLIAbueTP2w3JNCQmqX3AyG5xhnUfhq7y4R42WAwYgQ2x8OpUtA4zy nTVA== MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 4 Dec 2012 07:33:31 +1100 Subject: Re: Puzzling error msg. From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354566815 news.xs4all.nl 6891 [2001:888:2000:d::a6]:48773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34189 On Tue, Dec 4, 2012 at 4:37 AM, wrote: > Traceback (most recent call last): > File "./Connection_Monitor.py", line 146, in > Google_up, Google_summary, Google_RTT, Google_stddev = Google.connection_test() > File "/Users/wrw/Dev/Python/Connection_Monitor/Version2.2/WorkingCopy/network.py", line 101, in connection_test > # > IndexError: list index out of range > > > The routine is pasted in below: > > def connection_test(self): > self.network_up = True > self.error = None > ping_result = subprocess.Popen(['ping', '-qc6', self.target_IP], stderr = subprocess.PIPE, stdout = subprocess.PIPE).communicate()[0] > found_0 = '0 packets received' in ping_result > found_1 = '1 packets received' in ping_result > if found_0 == True or found_1 == True: > self.network_up = False > self.ping_summary = 'No route to host' > self.ping_RTT = 'NA' > self.ping_stddev = 'NA' > return self.network_up, self.ping_summary, self.ping_RTT, self.ping_stddev > # Is that the end of the function? What does it return if neither found_0 nor found_1? If that's the end, the function will be returning None (as all functions do on "flowing off the end"), but that would give a quite different error (namely, 'NoneType' is not iterable, at the unpacking). Is it possible that the error actually came from further up (with a faulty line number) and was actually because communicate() somehow returned an empty list? That's the only place in the code quoted that I'm seeing indexing, but communicate() is supposed to return a tuple, not a list. ChrisA