From 5151ef9e49f292af50cd7120881cdb173f228b95 Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Thu, 20 Oct 2011 23:17:04 +0200 Subject: add missing file --- For Weekly Test/tricode/ServerClassSoftware.py | 162 +++++++++ For Weekly Test/tricode/startTest2.php | 447 +++++++++++++++++++++++++ 2 files changed, 609 insertions(+) create mode 100644 For Weekly Test/tricode/ServerClassSoftware.py create mode 100644 For Weekly Test/tricode/startTest2.php (limited to 'For Weekly Test/tricode') diff --git a/For Weekly Test/tricode/ServerClassSoftware.py b/For Weekly Test/tricode/ServerClassSoftware.py new file mode 100644 index 0000000..206411e --- /dev/null +++ b/For Weekly Test/tricode/ServerClassSoftware.py @@ -0,0 +1,162 @@ +import socket +import sys +import os +import string +import signal + +class TimeoutException(Exception): + pass + +class ServerHandlerSoftware: + + def __init__(self,p): + self.port = p + self.host = None #symbolic name meaning all available interfaces + self.s = None + self.connected = 0 + self.address = "127.0.0.1" #address of the main controller + self.onceConnected = 0 + self.error = 'No error' + + self.debugMode = 0 + + def openSocket(self, timeoutVar): + self.error = 'No error' + for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, + socket.SOCK_STREAM, 0, socket.AI_PASSIVE): + af, socktype, proto, canonname, sa = res + + + try: + + self.s = socket.socket(af, socktype, proto) + self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets + self.s.settimeout(timeoutVar) + + except socket.error, msg: + self.s = None + self.connected = 0 + self.error = str(msg) + continue + + try: + self.s.bind(sa) + self.s.listen(1) + + except socket.error, msg: + self.s.close() + self.s = None + self.connected = 0 + self.error = str(msg) + continue + + break + + if self.s is None: + self.connected = 0 + return 0 + else: #accept the connection + try: + self.connection, self.address = self.s.accept() + self.s.settimeout(0) + self.connected = 1 + self.onceConnected = 1 + return 1 + except socket.timeout: + return 'TIMEOUT' + + def connectedTo(self): + return self.address + + def receiveData(self, timeout): + if self.connected == 1: + + def timeout_handler(signum, frame): + raise TimeoutException() + + try: + + old_handler = signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(timeout) #start the timeout alarm, for timeout seconds + + data = self.connection.recv(1024) + + #stop the timeout function + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + if not data: + self.connected = 0 + return 'NO DATA' + else: + return data + + except TimeoutException: + #timeout happened + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'TIMEOUT' + + except Exception, e: + #stop the timeout timer + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connected = 0 + if error[0:11] == '[Errno 104]': + return 3 #the other side reset the connection,[Errno 104] Connection reset by peer + + return 2 + else: + return 0 + + def sendData(self, data): + if self.connected == 1: + try: + self.connection.send(data) + return 1 + + except Exception, e: + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connecected = 0 + return 2 + else: + return 0 + + def closeConnection(self): + if self.onceConnected == 1: + try: + self.connected = 0 + SHUT_RDWR = 2 + self.connection.shutdown(SHUT_RDWR) + self.connection.close() + return 1 + except Exception, e: + self.connected = 0 + error = str(e) + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + if error[0:11] == '[Errno 107]': + return 3 #the other side closed the connection before us [Errno 107] Transport endpoint is not connected + return 2 + else: + return 0 + + def killPort(self): + killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read() + killResult = killResult.replace('\n','') + print killResult + if killResult!='': + print killResult + killPort = os.popen("kill -9 " + killResult).read() + return 1 + return 0 diff --git a/For Weekly Test/tricode/startTest2.php b/For Weekly Test/tricode/startTest2.php new file mode 100644 index 0000000..bc91847 --- /dev/null +++ b/For Weekly Test/tricode/startTest2.php @@ -0,0 +1,447 @@ + + + +Uni-Freiburg Network test + + + + + +
+Please select the type of the test you would like to perform or manually choose your tests! Then please press the submit button! +
+
+
+ + + + Warning + Simple test + Press simple test if you want to test the network for + + + + + + Warning + Smart test + This is just an example of what you can do using a CSS tooltip, feel free to get creative and produce your own! + + + + + + Warning + Full test + Press full test if you want to test every part of the university network. To execute this test the highest amount of time will be required, however this test produces the highest amount of information! + + + + + + Warning + Deselect all + Press deselect all if you want to deselect all the values you have selected to be executed for the test! + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+ + +
+
+
+ + + + + + -- cgit v1.2.3-55-g7522