HappyWeasel
파이썬 - ping check 본문
import subprocess
class pingStart:
def __init__(self, host):
self.__host = host
self.__status = "inactive"
print(self.checkPing())
def checkPing(self):
try:
result = subprocess.call(["ping", "-n", "1", self.__host], stdout=False)
if result == 0:
self.__status = "active"
else:
self.__status = "inactive"
return self.__host, self.__status
except subprocess.CalledProcessError:
self.__status = "err"
return self.__host, self.__status
'Basic > Python' 카테고리의 다른 글
파이썬 - 딕셔너리 (Dictionary) (0) | 2019.04.09 |
---|---|
파이썬 - 파이참(IDE) 단축키 (0) | 2019.04.09 |
파이썬 - 파일 입출력 (0) | 2019.04.09 |
파이썬 - port 확인 (0) | 2019.04.08 |
파이썬 - 현재 디렉터리 정보 가져오기 (0) | 2019.04.08 |
Comments