Corrected ICMP function
This commit is contained in:
parent
0fa8b49212
commit
9de12e1b10
@ -4,6 +4,7 @@ from abc import abstractmethod
|
|||||||
import time
|
import time
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from linecache import cache
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import psutil
|
import psutil
|
||||||
@ -113,8 +114,13 @@ def get_shell_value(command, args, callback=None):
|
|||||||
def is_ping(ip, count, callback=None):
|
def is_ping(ip, count, callback=None):
|
||||||
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
||||||
command = ['ping', param, str(count), ip]
|
command = ['ping', param, str(count), ip]
|
||||||
output = subprocess.check_output(command)
|
try:
|
||||||
result = 'unreachable' not in str(output) and 'could not find' not in str(output) and 'time out' not in str(output)
|
output = subprocess.check_output(command)
|
||||||
|
result = ('unreachable'.upper() not in str(output).upper() and
|
||||||
|
'could not find'.upper() not in str(output).upper() and
|
||||||
|
'time out'.upper() not in str(output).upper())
|
||||||
|
except:
|
||||||
|
result = False
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
callback(result)
|
callback(result)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user