Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Puzzling error msg.

Reply
Thread Tools

Re: Puzzling error msg.

 
 
Chris Angelico
Guest
Posts: n/a
 
      12-03-2012
On Tue, Dec 4, 2012 at 4:37 AM, <> wrote:
> Traceback (most recent call last):
> File "./Connection_Monitor.py", line 146, in <module>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Puzzling error msg. Steven D'Aprano Python 0 12-03-2012 06:12 PM
puzzling error Bill Cunningham C Programming 49 05-11-2011 06:30 PM
Puzzling JNI error message Roedy Green Java 9 10-12-2008 12:31 AM
puzzling error from GCC 3.4.4 drn@nadler.com C++ 6 10-08-2007 01:39 PM
puzzling error in script that copies files before processing them Ted Perl Misc 0 07-12-2006 03:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57