Currently, 'is_connected' attribute in SshServer is refered
before it is created, in Python 2.7.
This raises an Exception and the SSH operation won't work
anymore after this happens.
This commit ensures that 'is_connected' is created before
it is refered.

Signed-off-by: Satoshi Fujimoto <satoshi.fujimo...@gmail.com>
---
 ryu/services/protocols/bgp/operator/ssh.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/ryu/services/protocols/bgp/operator/ssh.py 
b/ryu/services/protocols/bgp/operator/ssh.py
index c228a89..cb2f63b 100644
--- a/ryu/services/protocols/bgp/operator/ssh.py
+++ b/ryu/services/protocols/bgp/operator/ssh.py
@@ -96,6 +96,16 @@ class SshServer(paramiko.ServerInterface):
         super(SshServer, self).__init__()
         self.sock = sock
         self.addr = addr
+        self.is_connected = True
+
+        # For pylint
+        self.buf = None
+        self.chan = None
+        self.curpos = None
+        self.histindex = None
+        self.history = None
+        self.prompted = None
+        self.promptlen = None
 
         # tweak InternalApi and RootCmd for non-bgp related commands
         self.api = InternalApi(log_handler=logging.StreamHandler(sys.stderr))
@@ -110,17 +120,6 @@ class SshServer(paramiko.ServerInterface):
         self.transport.add_server_key(host_key)
         self.transport.start_server(server=self)
 
-        self.is_connected = True
-
-        # For pylint
-        self.buf = None
-        self.chan = None
-        self.curpos = None
-        self.histindex = None
-        self.history = None
-        self.prompted = None
-        self.promptlen = None
-
     def check_auth_none(self, username):
         return paramiko.AUTH_SUCCESSFUL
 
@@ -260,7 +259,8 @@ class SshServer(paramiko.ServerInterface):
         self.curpos = curpos
         self._movcursor(curpos)
 
-    def _startnewline(self, prompt=None, buf=''):
+    def _startnewline(self, prompt=None, buf=None):
+        buf = buf or []
         if not prompt and self.prompted:
             prompt = self.PROMPT
         if isinstance(buf, str):
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to