summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-08-20 16:46:31 +0300
committerimarom <imarom@cisco.com>2015-08-20 16:46:31 +0300
commit479c4358ce64429a6d5e21b2bfeccd27da710701 (patch)
treee41ed3d0f60f0f496b131baff29edb6fce17b6b8
parentc3e34b2f9dfd3a9342bc2c773c3e5a92701a2d2c (diff)
forgot something on Python
-rwxr-xr-xsrc/console/trex_console.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/console/trex_console.py b/src/console/trex_console.py
index bd2af92a..2175fb5c 100755
--- a/src/console/trex_console.py
+++ b/src/console/trex_console.py
@@ -13,24 +13,17 @@ class TrexConsole(cmd.Cmd):
def __init__(self, rpc_client):
cmd.Cmd.__init__(self)
- rc, msg = rpc_client.connect()
- if not rc:
- print "\n*** " + msg
- self.prompt = "Trex (offline) > "
- else:
- self.prompt = "TRex > "
+ self.rpc_client = rpc_client
+
+ self.do_connect("")
self.intro = "\n-=TRex Console V1.0=-\n"
self.intro += "\nType 'help' or '?' for supported actions\n"
- self.rpc_client = rpc_client
self.verbose = False
-
- # before starting query the RPC server and add the methods
- rc, msg = self.rpc_client.query_rpc_server()
- if rc:
- self.supported_rpc = [str(x) for x in msg if x]
+ self.postcmd(False, "")
+
# a cool hack - i stole this function and added space
def completenames(self, text, *ignored):
@@ -81,14 +74,21 @@ class TrexConsole(cmd.Cmd):
print "[SUCCESS]\n"
else:
print "\n*** " + msg + "\n"
+ return
- def do_reconnect (self, line):
- '''Reconnects to the server\n'''
- rc, msg = self.rpc_client.reconnect()
+ def do_connect (self, line):
+ '''Connects to the server\n'''
+ rc, msg = self.rpc_client.connect()
if rc:
print "[SUCCESS]\n"
else:
print "\n*** " + msg + "\n"
+ return
+
+ rc, msg = self.rpc_client.query_rpc_server()
+
+ if rc:
+ self.supported_rpc = [str(x) for x in msg if x]
def do_rpc (self, line):
'''Launches a RPC on the server\n'''
@@ -158,6 +158,7 @@ class TrexConsole(cmd.Cmd):
if self.rpc_client.is_connected():
self.prompt = "TRex > "
else:
+ self.supported_rpc = None
self.prompt = "TRex (offline) > "
return stop