Skip to content
Snippets Groups Projects
Commit c188bee3 authored by Brian O'Connor's avatar Brian O'Connor
Browse files

Fixed divide by 0 error in ping command when no packets are sent

fixes #143
parent adf391fd
No related branches found
No related tags found
No related merge requests found
......@@ -468,9 +468,13 @@ def ping( self, hosts=None, timeout=None ):
lost += sent - received
output( ( '%s ' % dest.name ) if received else 'X ' )
output( '\n' )
if packets > 0:
ploss = 100 * lost / packets
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
( ploss, lost, packets ) )
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
( ploss, lost, packets ) )
else:
ploss = 0
output( "*** Warning: No packets sent\n" )
return ploss
@staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment