From 92eed03aeeb1c905a33546392a7bff3337b607c8 Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Sun, 30 Oct 2011 22:29:21 +0100 Subject: rearrange the files and edit ssh connection for class controller --- For Weekly Test/tricode/ControllerClass.py | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'For Weekly Test/tricode/ControllerClass.py') diff --git a/For Weekly Test/tricode/ControllerClass.py b/For Weekly Test/tricode/ControllerClass.py index 1a25361..d6ee603 100755 --- a/For Weekly Test/tricode/ControllerClass.py +++ b/For Weekly Test/tricode/ControllerClass.py @@ -30,34 +30,42 @@ class doTheTest: def FuncTest(self): - logger.logEvent('') + logger.logEvent(' -- -X- --') self.initCaller() if self.callFrom =="GSMRZ3" or self.callFrom =="GSMRZ2": # wait until ssh connection establish - sleep(6) + if self.continues == 1: + sleep(6) + self.callerGreeting() + else: + self.connected = 'NOT OK' else: sleep(2) - self.callerGreeting() + self.callerGreeting() if self.connected == 'OK': self.caller.sendData('CALLER|'+self.destNo) - callerHandler = self.caller.receiveData(20) + callerHandler = self.caller.receiveData(25) if callerHandler == "CALLER READY": logger.logEvent('Caller handler : Ready') self.initReceiver() if self.dest =="GSMRZ3" or self.dest =="GSMRZ2": # wait until ssh connection establish - sleep(6) + if self.continues == 1: + sleep(6) + self.receiverGreeting() + else: + self.connected = 'NOT OK' else: sleep(2) - self.receiverGreeting() + self.receiverGreeting() if self.connected == 'OK': self.receiver.sendData('RECEIVER') - destHandler = self.receiver.receiveData(20) + destHandler = self.receiver.receiveData(25) if destHandler == 'RECEIVER READY': logger.logEvent('Receiver handler : Ready') @@ -104,6 +112,7 @@ class doTheTest: def initCancelTest(self): #close SSH connection when using gsmBox and destination doesnt respond. to make sure SSH connection are terminate + logger.logEvent('init Cancel test') if self.callFrom[0:5] == 'GSMRZ': if self.callFrom != 'GSMRZ1': # close SSH tunneling @@ -176,9 +185,10 @@ class doTheTest: self.initAccount(self.accCaller) #open SSH tunneling self.boxCaller = SSHTunnelBoxClass.SSHTunneling(self.portCaller, 50008, self.server, self.username, self.password) - self.boxCaller.startTunneling() - - + if int(self.boxCaller.startTunneling()) != 0: + self.continues = 1 + else: + self.continues = 0 elif self.callFrom[0:4] == 'GSME': self.initGSM(self.portCaller, self.callPortName, self.callFrom) @@ -199,6 +209,10 @@ class doTheTest: #open SSH tunneling self.boxDest = SSHTunnelBoxClass.SSHTunneling(self.portDest, 50008, self.server, self.username, self.password) self.boxDest.startTunneling() + if int(self.boxCaller.startTunneling()) != 0: + self.continues = 1 + else: + self.continues = 0 elif self.dest[0:4] == 'GSME': self.initGSM(self.portDest, self.destPortName, self.dest) @@ -209,6 +223,7 @@ class doTheTest: # send terminate message to Handlers def initTerminate(self): + logger.logEvent('TERMINATE CONNECTION') self.caller.sendData('TERMINATE CONNECTION') self.receiver.sendData('TERMINATE CONNECTION') if self.callFrom[0:5] == 'GSMRZ': @@ -223,6 +238,7 @@ class doTheTest: self.caller.closeConnection() def callerGreeting(self): # send greeting message to the caller handler + logger.logEvent('Caller Greeting') self.connected = None #open connection to the Handler self.caller = ClientClass.Connection('localhost',self.portCaller) @@ -243,6 +259,7 @@ class doTheTest: self.connected = 'NOT OK' def receiverGreeting(self): # send greeting message to the destination handler + logger.logEvent('Receiver Greeting') self.connected = None #open connection to the Handler self.receiver = ClientClass.Connection('localhost', self.portDest) @@ -265,6 +282,7 @@ class doTheTest: def initGSM(self, portCommunication, portDevice, handler): #open GSM Handler + logger.logEvent('Init GSM') subprocess.Popen(args=["gnome-terminal", '--command=python GSMHandler.py '+str(portCommunication)+ ' ' +str(portDevice)+' '+str(handler)]) -- cgit v1.2.3-55-g7522