Stop catching non error throwables such as SystemExit
* Convert "except:" to "except Exception:"
* Use log.exception instead of directly calling traceback
* Remove unused imports
* Fix a typos
* Replace tabs with spaces for combatibility issues
diff --git a/TestON/drivers/common/cli/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index 057a3f1..ee26bde 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -1,16 +1,8 @@
"""
Driver for blank dataplane VMs. Created for SDNIP test.
"""
-import time
import pexpect
-import struct
-import fcntl
-import os
import sys
-import signal
-import sys
-import re
-import json
sys.path.append( "../" )
from drivers.common.clidriver import CLI
@@ -95,15 +87,15 @@
self.handle.sendline( "" )
self.handle.expect( "\$" )
- self.handle.sendline( "scp " + str( destlogin ) + "@" +
- str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
- str( net ) + ".txt" )
-
- i = self.handle.expect( [
- "100%",
+ self.handle.sendline( "scp " + str( destlogin ) + "@" +
+ str( destip ) + ":/tmp/local_ip.txt /tmp/ip_table" +
+ str( netsrc ) + ".txt" )
+
+ i = self.handle.expect( [
+ "100%",
"password",
pexpect.TIMEOUT ],
- timeout=30 )
+ timeout=30 )
if i == 0:
main.log.info( "Copied ping file successfully" )
@@ -120,20 +112,20 @@
self.handle.expect( "\$" )
main.log.info( "Pinging interfaces on the " + str( netdst ) +
- " network from " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1" )
+ " network from " + str( netsrc ) + "." +
+ str( netstrt ) + ".1.1" )
self.handle.sendline( "sudo fping -S " + str( netsrc ) + "." +
- str( netstrt ) + ".1.1 -f /tmp/ip_table" +
- str( netdst ) + ".txt" )
+ str( netstrt ) + ".1.1 -f /tmp/ip_table" +
+ str( netdst ) + ".txt" )
while 1:
i = self.handle.expect( [
- "reachable",
+ "reachable",
"unreachable",
"\$",
"password",
pexpect.TIMEOUT,
"not installed" ],
- timeout=45 )
+ timeout=45 )
if i == 0:
result = main.TRUE
elif i == 1:
@@ -142,6 +134,7 @@
return result
elif i == 2:
main.log.info( "All interfaces reachable" )
+ result = main.FALSE
return result
elif i == 3:
self.handle.sendline( self.pwd )
@@ -183,8 +176,8 @@
try:
self.handle.sendline( "exit" )
self.handle.expect( "closed" )
- except:
- main.log.error( "Connection failed to the host" )
+ except Exception:
+ main.log.exception( "Connection failed to the host" )
response = main.FALSE
return response