From b99193ba68f947802245a288940e54904ecbee61 Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Fri, 18 Nov 2011 13:23:49 +0100 Subject: final version --- Under-Testing/Server-Code-New/PingClass.py | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 Under-Testing/Server-Code-New/PingClass.py (limited to 'Under-Testing/Server-Code-New/PingClass.py') diff --git a/Under-Testing/Server-Code-New/PingClass.py b/Under-Testing/Server-Code-New/PingClass.py deleted file mode 100644 index e13b32b..0000000 --- a/Under-Testing/Server-Code-New/PingClass.py +++ /dev/null @@ -1,28 +0,0 @@ -import subprocess -import string - -class Ping: - - def __init__(self, pingAddress): - self.pingAddress = pingAddress - - def ping(self,numberTries): - tried = 1 - while numberTries >= tried: - tried += 1 - #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds - ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] - - pingAlive = int(string.find(ping_cmd, '1 received')) - unknownHost = int(string.find(ping_cmd, 'unknown host')) - - - if pingAlive != -1: - break - - if unknownHost != -1: - return 2 #unknown host - if pingAlive != -1: - return 1 #ping works fine - else: - return 0 #no ping response -- cgit v1.2.3-55-g7522