Merge pull request #75 from opennetworkinglab/devl/disconnect_bug

Devl/disconnect bug
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 8934e50..3f07691 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -47,9 +47,6 @@
 
 from core.utilities import Utilities
 
-import logging 
-import datetime
-from optparse import OptionParser
 
 class TestON:
     '''
@@ -79,11 +76,11 @@
         self.init_result = self.TRUE
         self.testResult = "Summary"
         self.stepName =""
-        self.EXPERIMENTAL_MODE = False   
+        self.EXPERIMENTAL_MODE = False
         self.test_target = None
         self.lastcommand = None
-        self.testDir = tests_path 
-        self.configFile = config_path + "teston.cfg" 
+        self.testDir = tests_path
+        self.configFile = config_path + "teston.cfg"
         self.parsingClass = "xmlparser"
         self.parserPath = core_path + "/xmlparser"
         self.loggerPath = core_path + "/logger"
@@ -111,7 +108,7 @@
                 if 'test_target' in self.componentDictionary[component].keys():
                     self.test_target = component
              
-        # Checking for the openspeak file and test script 
+        # Checking for the openspeak file and test script
         self.logger.initlog(self)
 
         # Creating Drivers Handles
@@ -151,7 +148,7 @@
         '''
         global driver_options
         self.log.info("Creating component Handle: "+component)
-        driver_options = {}         
+        driver_options = {}
         if 'COMPONENTS' in self.componentDictionary[component].keys():
             driver_options =dict(self.componentDictionary[component]['COMPONENTS'])
 
@@ -171,7 +168,7 @@
                                               options = driver_options)
         if not connect_result:
             self.log.error("Exiting form the test execution because the connecting to the "+component+" component failed.")
-            self.exit() 
+            self.exit()
             
         vars(self)[component] = driverObject
                         
@@ -186,7 +183,7 @@
         self.testCaseResult = {}
         self.TOTAL_TC = 0
         self.TOTAL_TC_RUN = 0
-        self.TOTAL_TC_PLANNED = 0 
+        self.TOTAL_TC_PLANNED = 0
         self.TOTAL_TC_NORESULT = 0
         self.TOTAL_TC_FAIL = 0
         self.TOTAL_TC_PASS = 0
@@ -194,7 +191,7 @@
         self.stepCount = 0
         self.CASERESULT = self.TRUE
         
-        import testparser 
+        import testparser
         testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py"
         test = testparser.TestParser(testFile)
         self.testscript = test.testscript
@@ -205,8 +202,8 @@
         result = self.TRUE
 	while(repeat):
             for self.CurrentTestCaseNumber in self.testcases_list:
-                result = self.runCase(self.CurrentTestCaseNumber) 
-	    repeat-=1                   
+                result = self.runCase(self.CurrentTestCaseNumber)
+	    repeat-=1
         return result
     
     def runCase(self,testCaseNumber):
@@ -219,7 +216,7 @@
         stopped = False
         try :
             self.stepList = self.code[self.testCaseNumber].keys()
-        except KeyError,e:
+        except KeyError:
             main.log.error("There is no Test-Case "+ self.testCaseNumber)
             return main.FALSE
         
@@ -258,8 +255,8 @@
         
     def addCaseHeader(self):
         caseHeader = "\n"+"*" * 30+"\n Result summary for Testcase"+str(self.CurrentTestCaseNumber)+"\n"+"*" * 30+"\n"
-        self.log.exact(caseHeader) 
-        caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : " 
+        self.log.exact(caseHeader)
+        caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : "
         for driver in self.componentDictionary.keys():
             vars(self)[driver+'log'].info(caseHeader)
     
@@ -282,28 +279,29 @@
         '''
         result = self.TRUE
         self.logger.testSummary(self)
-        
+
         #self.reportFile.close()
-        
+
 
         #utilities.send_mail()
         try :
             for component in self.componentDictionary.keys():
-                tempObject  = vars(self)[component]    
-                print "Disconnecting "+str(tempObject)
-         
+                tempObject  = vars(self)[component]
+                print "Disconnecting " + str(tempObject)
                 tempObject.disconnect()
-            #tempObject.execute(cmd="exit",prompt="(.*)",timeout=120) 
+            #tempObject.execute(cmd="exit",prompt="(.*)",timeout=120)
 
         except(Exception):
+            self.log.exception( "Exception while disconnecting from " +
+                                 str( component ) )
             #print " There is an error with closing hanldes"
             result = self.FALSE
         # Closing all the driver's session files
         for driver in self.componentDictionary.keys():
            vars(self)[driver].close_log_handles()
-           
+
         return result
-        
+
     def pause(self):
         '''
         This function will pause the test's execution, and will continue after user provide 'resume' command.
@@ -380,7 +378,7 @@
         if self.stepCount > 1 :
             stepHeader = "\n"+"-"*45+"\nEnd of Step "+previousStep+"\n"+"-"*45+"\n"
         
-        stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n" 
+        stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n"
         for driver in self.componentDictionary.keys():
             vars(self)[driver+'log'].info(stepHeader)
             
@@ -388,10 +386,10 @@
         '''
            Test's each test-case information will append to the logs.
         '''
-        self.CurrentTestCase = testCaseName 
+        self.CurrentTestCase = testCaseName
         testCaseName = " " + str(testCaseName) + ""
         self.log.case(testCaseName)
-        caseHeader = testCaseName+"\n"+"*" * 40+"\n" 
+        caseHeader = testCaseName+"\n"+"*" * 40+"\n"
         for driver in self.componentDictionary.keys():
             vars(self)[driver+'log'].info(caseHeader)
         
@@ -423,7 +421,7 @@
         ''' It will load the default response parser '''
         response_dict = {}
         response_dict = self.response_to_dict(response, return_format)
-        return_format_string = self.dict_to_return_format(response,return_format,response_dict)   
+        return_format_string = self.dict_to_return_format(response,return_format,response_dict)
         return return_format_string
     
     def response_to_dict(self,response,return_format):
@@ -434,7 +432,7 @@
         ini_match = re.search('^\s*\[', response)
         if json_match :
             main.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format")
-            # Formatting the json string 
+            # Formatting the json string
             
             response = re.sub(r"{\s*'?(\w)", r'{"\1', response)
             response = re.sub(r",\s*'?(\w)", r',"\1', response)
@@ -454,14 +452,13 @@
             from configobj import ConfigObj
             response_file = open("respnse_file.temp",'w')
             response_file.write(response)
-            response_file.close() 
+            response_file.close()
             response_dict = ConfigObj("respnse_file.temp")
             return response_dict
             
         elif xml_match :
             main.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format")
             try :
-                from core import dicttoobject
                 response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
             except Exception, e:
                 main.log.error(e)
@@ -485,7 +482,7 @@
                         table_data = table_data + get_table(temp_val)
                 else :
                     table_data = table_data + str(value_to_convert) +"\t"
-                return table_data 
+                return table_data
             
             for value in response_dict.values() :
                 response_table =  response_table + get_table(value)
@@ -510,7 +507,6 @@
             
         elif return_format == 'xml':
             ''' Will return in xml format'''
-            from core import dicttoobject
             response_xml = xmldict.dict_to_xml(response_dict)
             response_xml = re.sub(">\s*<", ">\n<", response_xml)
             return "\n"+response_xml
@@ -566,14 +562,14 @@
         main.classPath = "examples."+main.TEST+"."+main.TEST
                
 def verifyLogdir(options):
-    #Verifying Log directory option      
+    #Verifying Log directory option
     if options.logdir:
         main.logdir = options.logdir
     else :
-        main.logdir = main.FALSE  
+        main.logdir = main.FALSE
         
 def verifyMail(options):
-    # Checking the mailing list 
+    # Checking the mailing list
     if options.mail:
         main.mail = options.mail
     elif main.params.has_key('mail'):
@@ -582,10 +578,10 @@
         main.mail = 'paxweb@paxterrasolutions.com'
 
 def verifyTestCases(options):
-    #Getting Test cases list 
+    #Getting Test cases list
     if options.testcases:
-	testcases_list = options.testcases 
-        #sys.exit() 
+	testcases_list = options.testcases
+        #sys.exit()
         testcases_list = re.sub("(\[|\])", "", options.testcases)
         main.testcases_list = eval(testcases_list+",")
     else :
@@ -604,16 +600,16 @@
 	            if type(testcase)==int:
 		        testcase=[testcase]
 	            list1.extend(testcase)
-	    main.testcases_list=list1	                                     
+	    main.testcases_list=list1
         else :
             print "testcases not specifed in params, please provide in params file or 'testcases' commandline argument"
-            sys.exit() 
+            sys.exit()
                   
 def verifyTestScript(options):
     '''
     Verifyies test script.
     '''
-    main.openspeak = openspeak.OpenSpeak()        
+    main.openspeak = openspeak.OpenSpeak()
     openspeakfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".ospk"
     testfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".py"
     if os.path.exists(openspeakfile) :
@@ -629,20 +625,20 @@
         testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1)
     except(ImportError):
         print "There was an import error, it might mean that there is no test like "+main.TEST
-        main.exit()       
+        main.exit()
 
     testClass = getattr(testModule, main.TEST)
     main.testObject = testClass()
     load_parser()
-    main.params = main.parser.parseParams(main.classPath)    
-    main.topology = main.parser.parseTopology(main.classPath) 
+    main.params = main.parser.parseParams(main.classPath)
+    main.topology = main.parser.parseTopology(main.classPath)
     
 def verifyParams():
     try :
         main.params = main.params['PARAMS']
     except(KeyError):
         print "Error with the params file: Either the file not specified or the format is not correct"
-        main.exit()            
+        main.exit()
     
     try :
         main.topology = main.topology['TOPOLOGY']
@@ -681,9 +677,9 @@
                     main.exit()
             else :
                 print "No Such File Exists !!"+ confighash['config']['parser']['file'] +"using default parser"
-                load_defaultParser() 
-        elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :  
-            load_defaultParser() 
+                load_defaultParser()
+        elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+            load_defaultParser()
     else:
         load_defaultParser()
 
@@ -694,7 +690,7 @@
     moduleList = main.parserPath.split("/")
     newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
     try :
-        parsingClass = main.parsingClass 
+        parsingClass = main.parsingClass
         parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
         parsingClass = getattr(parsingModule, parsingClass)
         main.parser = parsingClass()
@@ -733,8 +729,8 @@
             else :
                 print "No Such File Exists !!"+confighash['config']['logger']['file']+ "Using default logger"
                 load_defaultlogger()
-        elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :  
-            load_defaultlogger() 
+        elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+            load_defaultlogger()
     else:
         load_defaultlogger()
 
@@ -745,14 +741,14 @@
     moduleList = main.loggerPath.split("/")
     newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
     try :
-        loggerClass = main.loggerClass 
+        loggerClass = main.loggerClass
         loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
         loggerClass = getattr(loggerModule, loggerClass)
         main.logger = loggerClass()
 
     except ImportError:
         print sys.exc_info()[1]
-        main.exit()    
+        main.exit()
 
 def load_defaultlogger():
     '''
@@ -761,7 +757,7 @@
     moduleList = main.loggerPath.split("/")
     newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
     try :
-        loggerClass = main.loggerClass 
+        loggerClass = main.loggerClass
         loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
         loggerClass = getattr(loggerModule, loggerClass)
         main.logger = loggerClass()
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 57fa94d..4dd6d28 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1256,22 +1256,20 @@
         disconnect the handle.
         """
         self.handle.sendline('')
-        i = 1
-        i = self.handle.expect( ['mininet>',pexpect.EOF,pexpect.TIMEOUT ], timeout = 2)
+        i = self.handle.expect( [ 'mininet>', pexpect.EOF, pexpect.TIMEOUT ],
+                                timeout = 2)
         if i == 0:
             self.stopNet()
-        response = ''
+        elif i == 1:
+            return main.TRUE
+        response = main.TRUE
         # print "Disconnecting Mininet"
         if self.handle:
             self.handle.sendline( "exit" )
             self.handle.expect( "exit" )
             self.handle.expect( "(.*)" )
-            main.log.info( "Mininet CLI is successfully disconnected" )
-            response = main.TRUE
         else:
             main.log.error( "Connection failed to the host" )
-            response = main.FALSE
-
         return response
 
     def stopNet( self ):
@@ -1280,10 +1278,10 @@
         Returns main.TRUE if the mininet succesfully stops and
                 main.FALSE if the pexpect handle does not exist.
 
-        Will cleanuop and exit the test if mininet fails to stop
+        Will cleanup and exit the test if mininet fails to stop
         """
 
-        main.log.info( self.name + ": Disconnecting mininet..." )
+        main.log.info( self.name + ": Stopping mininet..." )
         response = ''
         if self.handle:
             try:
@@ -1291,7 +1289,7 @@
                     cmd="exit",
                     prompt="(.*)",
                     timeout=120 )
-                main.log.info( self.name + ": Disconnected")
+                main.log.info( self.name + ": Stopped")
                 self.handle.sendline( "sudo mn -c" )
                 response = main.TRUE
             except pexpect.EOF:
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 3d91a20..389a077 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -336,7 +336,6 @@
         try:
             self.handle.sendline( "sudo pkill tcpdump" )
             self.handle.sendline( "" )
-            self.handle.sendline( "" )
             self.handle.expect( "\$" )
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -374,12 +373,7 @@
         """
         Called at the end of the test to disconnect the handle.
         """
-        response = ''
-        # print "Disconnecting Mininet"
         if self.handle:
-            self.handle.sendline( "exit" )
-            self.handle.expect( "exit" )
-            self.handle.expect( "(.*)" )
             # Close the ssh connection
             self.handle.sendline( "" )
             self.handle.expect( "\$" )
@@ -387,6 +381,7 @@
             self.handle.expect( "closed" )
         else:
             main.log.error( "Connection failed to the host" )
+        return main.TRUE
 
     def getFlowTable( self, protoVersion, sw ):
         """
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 5deb911..48f516d 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -76,7 +76,7 @@
         """
         Called when Test is complete to disconnect the ONOS handle.
         """
-        response = ''
+        response = main.TRUE
         try:
             self.handle.sendline( "" )
             i = self.handle.expect( [ "onos>", "\$" ] )
@@ -92,7 +92,7 @@
 
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
-            return None
+            response = main.FALSE
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":     " + self.handle.before )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 4719150..c2b3693 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -45,7 +45,7 @@
                 if key == "home":
                     self.home = self.options[ 'home' ]
                     break
-            if self.home == None or self.home == "":
+            if self.home is None or self.home == "":
                 self.home = "~/ONOS"
 
             self.name = self.options[ 'name' ]
@@ -79,7 +79,7 @@
         """
         Called when Test is complete to disconnect the ONOS handle.
         """
-        response = ''
+        response = main.TRUE
         try:
             self.handle.sendline( "" )
             self.handle.expect( "\$" )
@@ -169,8 +169,8 @@
             self.handle.expect( "mvn clean install" )
             while True:
                 i = self.handle.expect( [
-                    'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s\
-                            Runtime\sEnvironment\sto\scontinue',
+                    'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s' +
+                        'Runtime\sEnvironment\sto\scontinue',
                     'BUILD\sFAILURE',
                     'BUILD\sSUCCESS',
                     'ONOS\$',
@@ -205,8 +205,8 @@
                     main.cleanup()
                     main.exit()
                 else:
-                    main.log.error( self.name + ": unexpected response from \
-                            mvn clean install" )
+                    main.log.error( self.name + ": unexpected response from " +
+                            "mvn clean install" )
                     # return main.FALSE
                     main.cleanup()
                     main.exit()
@@ -254,10 +254,8 @@
                     'Already up-to-date',
                     'Aborting',
                     'You\sare\snot\scurrently\son\sa\sbranch',
-                    'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\
-                            \sbranch\syou',
-                    'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\
-                            \sfiles',
+                    'You asked me to pull without telling me which branch you',
+                    'Pull is not possible because you have unmerged files',
                     pexpect.TIMEOUT ],
                 timeout=300 )
             # debug
@@ -285,27 +283,26 @@
             elif i == 4:
                 main.log.info(
                     self.name +
-                    ": Git Pull - Aborting...\
-                            Are there conflicting git files?" )
+                    ": Git Pull - Aborting..." +
+                    "Are there conflicting git files?" )
                 return main.ERROR
             elif i == 5:
                 main.log.info(
                     self.name +
-                    ": Git Pull - You are not currently\
-                            on a branch so git pull failed!" )
+                    ": Git Pull - You are not currently " +
+                    "on a branch so git pull failed!" )
                 return main.ERROR
             elif i == 6:
                 main.log.info(
                     self.name +
-                    ": Git Pull - You have not configured\
-                             an upstream branch to pull from\
-                             . Git pull failed!" )
+                    ": Git Pull - You have not configured an upstream " +
+                    "branch to pull from. Git pull failed!" )
                 return main.ERROR
             elif i == 7:
                 main.log.info(
                     self.name +
-                    ": Git Pull - Pull is not possible\
-                            because you have unmerged files." )
+                    ": Git Pull - Pull is not possible because " +
+                    "you have unmerged files." )
                 return main.ERROR
             elif i == 8:
                 main.log.error( self.name + ": Git Pull - TIMEOUT" )
@@ -348,27 +345,23 @@
         try:
             self.handle.sendline( "cd " + self.home )
             self.handle.expect( self.home + "\$" )
-            main.log.info(
-                self.name +
-                ": Checking out git branch: " +
-                branch +
-                "..." )
+            main.log.info( self.name +
+                           ": Checking out git branch/ref: " + branch + "..." )
             cmd = "git checkout " + branch
             self.handle.sendline( cmd )
             self.handle.expect( cmd )
             i = self.handle.expect(
-                [
-                    'fatal',
-                    'Username\sfor\s(.*):\s',
-                    'Already\son\s\'',
-                    'Switched\sto\sbranch\s\'' +
-                    str( branch ),
-                    pexpect.TIMEOUT,
-                    'error: Your local changes to the following files\
-                            would be overwritten by checkout:',
-                    'error: you need to resolve your current index first' ],
+                [ 'fatal',
+                  'Username\sfor\s(.*):\s',
+                  'Already\son\s\'',
+                  'Switched\sto\sbranch\s\'' + str( branch ),
+                  pexpect.TIMEOUT,
+                  'error: Your local changes to the following files' +
+                          'would be overwritten by checkout:',
+                  'error: you need to resolve your current index first',
+                  "You are in 'detached HEAD' state.",
+                  "HEAD is now at " ],
                 timeout=60 )
-
             if i == 0:
                 main.log.error(
                     self.name +
@@ -381,12 +374,12 @@
                     ": Git checkout asking for username." +
                     " Please configure your local git repository to be able " +
                     "to access your remote repository passwordlessly" )
+                # TODO add support for authenticating
                 return main.ERROR
             elif i == 2:
                 main.log.info(
                     self.name +
-                    ": Git Checkout %s : Already on this branch" %
-                    branch )
+                    ": Git Checkout %s : Already on this branch" % branch )
                 self.handle.expect( self.home + "\$" )
                 # main.log.info( "DEBUG: after checkout cmd = "+
                 # self.handle.before )
@@ -394,8 +387,7 @@
             elif i == 3:
                 main.log.info(
                     self.name +
-                    ": Git checkout %s - Switched to this branch" %
-                    branch )
+                    ": Git checkout %s - Switched to this branch" % branch )
                 self.handle.expect( self.home + "\$" )
                 # main.log.info( "DEBUG: after checkout cmd = "+
                 # self.handle.before )
@@ -403,33 +395,45 @@
             elif i == 4:
                 main.log.error( self.name + ": Git Checkout- TIMEOUT" )
                 main.log.error(
-                    self.name + " Response was: " + str(
-                        self.handle.before ) )
+                    self.name + " Response was: " + str( self.handle.before ) )
                 return main.ERROR
             elif i == 5:
                 self.handle.expect( "Aborting" )
                 main.log.error(
                     self.name +
                     ": Git checkout error: \n" +
-                    "Your local changes to the following\
-                            files would be overwritten by checkout:" +
-                    str(
-                        self.handle.before ) )
+                    "Your local changes to the following files would" +
+                    " be overwritten by checkout:" +
+                    str( self.handle.before ) )
                 self.handle.expect( self.home + "\$" )
                 return main.ERROR
             elif i == 6:
-                main.log.error( self.name +
-                                ": Git checkout error: \n" +
-                                "You need to resolve your\
-                                        current index first:" +
-                                str( self.handle.before ) )
+                main.log.error(
+                    self.name +
+                    ": Git checkout error: \n" +
+                    "You need to resolve your current index first:" +
+                    str( self.handle.before ) )
                 self.handle.expect( self.home + "\$" )
                 return main.ERROR
+            elif i == 7:
+                main.log.info(
+                    self.name +
+                    ": Git checkout " + str( branch ) +
+                    " - You are in 'detached HEAD' state. HEAD is now at " +
+                    str( branch ) )
+                self.handle.expect( self.home + "\$" )
+                return main.TRUE
+            elif i == 8:  # Already in detached HEAD on the specified commit
+                main.log.info(
+                    self.name +
+                    ": Git Checkout %s : Already on commit" % branch )
+                self.handle.expect( self.home + "\$" )
+                return main.TRUE
             else:
                 main.log.error(
                     self.name +
-                    ": Git Checkout - Unexpected response,\
-                            check for pull errors" )
+                    ": Git Checkout - Unexpected response, " +
+                    "check for pull errors" )
                 main.log.error( self.name + ":     " + self.handle.before )
                 return main.ERROR
 
@@ -447,7 +451,7 @@
 
     def getVersion( self, report=False ):
         """
-        Writes the COMMIT number to the report to be parsed\
+        Writes the COMMIT number to the report to be parsed
                 by Jenkins data collecter.
         """
         try:
@@ -456,8 +460,8 @@
             self.handle.sendline(
                 "cd " +
                 self.home +
-                "; git log -1 --pretty=fuller --decorate=short | grep -A 6\
-                        \"commit\" --color=never" )
+                "; git log -1 --pretty=fuller --decorate=short | grep -A 6 " +
+                " \"commit\" --color=never" )
             # NOTE: for some reason there are backspaces inserted in this
             # phrase when run from Jenkins on some tests
             self.handle.expect( "never" )
@@ -1219,13 +1223,13 @@
                 result = main.TRUE
             else:
                 output = output + \
-                    "The number of links and switches does not match\
-                    what was expected"
+                    "The number of links and switches does not match " + \
+                    "what was expected"
                 result = main.FALSE
-            output = output + "\n ONOS sees %i devices (%i expected)\
-                     and %i links (%i expected)" %\
-                     ( int( devices ), int( numoswitch ),
-                       int( links ), int( numolink ) )
+            output = output + "\n ONOS sees %i devices" % int ( devices )
+            output = output + " (%i expected) " %  int( numoswitch )
+            output = output + "and %i links " % int( links )
+            output = output + "(%i expected)" % int( numolink )
             if logLevel == "report":
                 main.log.report( output )
             elif logLevel == "warn":