Revision 030b950d ncclient/transport/ssh.py

b/ncclient/transport/ssh.py
27 27
logger = logging.getLogger('ncclient.transport.ssh')
28 28

  
29 29
BUF_SIZE = 4096
30
MSG_DELIM = ']]>]]>'
30
MSG_DELIM = "]]>]]>"
31 31
TICK = 0.1
32 32

  
33 33
def default_unknown_host_cb(host, fingerprint):
......
228 228
        self._connected = True # there was no error authenticating
229 229

  
230 230
        c = self._channel = self._transport.open_session()
231
        c.set_name('netconf')
232
        c.invoke_subsystem('netconf')
231
        c.set_name("netconf")
232
        c.invoke_subsystem("netconf")
233 233

  
234 234
        self._post_connect()
235 235
    
......
242 242
            for cls in (paramiko.RSAKey, paramiko.DSSKey):
243 243
                try:
244 244
                    key = cls.from_private_key_file(key_filename, password)
245
                    logger.debug('Trying key %s from %s' %
245
                    logger.debug("Trying key %s from %s" %
246 246
                              (hexlify(key.get_fingerprint()), key_filename))
247 247
                    self._transport.auth_publickey(username, key)
248 248
                    return
......
253 253
        if allow_agent:
254 254
            for key in paramiko.Agent().get_keys():
255 255
                try:
256
                    logger.debug('Trying SSH agent key %s' %
256
                    logger.debug("Trying SSH agent key %s" %
257 257
                                 hexlify(key.get_fingerprint()))
258 258
                    self._transport.auth_publickey(username, key)
259 259
                    return
......
263 263

  
264 264
        keyfiles = []
265 265
        if look_for_keys:
266
            rsa_key = os.path.expanduser('~/.ssh/id_rsa')
267
            dsa_key = os.path.expanduser('~/.ssh/id_dsa')
266
            rsa_key = os.path.expanduser("~/.ssh/id_rsa")
267
            dsa_key = os.path.expanduser("~/.ssh/id_dsa")
268 268
            if os.path.isfile(rsa_key):
269 269
                keyfiles.append((paramiko.RSAKey, rsa_key))
270 270
            if os.path.isfile(dsa_key):
271 271
                keyfiles.append((paramiko.DSSKey, dsa_key))
272 272
            # look in ~/ssh/ for windows users:
273
            rsa_key = os.path.expanduser('~/ssh/id_rsa')
274
            dsa_key = os.path.expanduser('~/ssh/id_dsa')
273
            rsa_key = os.path.expanduser("~/ssh/id_rsa")
274
            dsa_key = os.path.expanduser("~/ssh/id_dsa")
275 275
            if os.path.isfile(rsa_key):
276 276
                keyfiles.append((paramiko.RSAKey, rsa_key))
277 277
            if os.path.isfile(dsa_key):
......
280 280
        for cls, filename in keyfiles:
281 281
            try:
282 282
                key = cls.from_private_key_file(filename, password)
283
                logger.debug('Trying discovered key %s in %s' %
283
                logger.debug("Trying discovered key %s in %s" %
284 284
                          (hexlify(key.get_fingerprint()), filename))
285 285
                self._transport.auth_publickey(username, key)
286 286
                return
......
300 300
            # need pep-3134 to do this right
301 301
            raise AuthenticationError(repr(saved_exception))
302 302

  
303
        raise AuthenticationError('No authentication methods available')
303
        raise AuthenticationError("No authentication methods available")
304 304

  
305 305
    def run(self):
306 306
        chan = self._channel
......
323 323
                    else:
324 324
                        raise SessionCloseError(self._buffer.getvalue())
325 325
                if not q.empty() and chan.send_ready():
326
                    logger.debug('sending message')
326
                    logger.debug("Sending message")
327 327
                    data = q.get() + MSG_DELIM
328 328
                    while data:
329 329
                        n = chan.send(data)
......
331 331
                            raise SessionCloseError(self._buffer.getvalue(), data)
332 332
                        data = data[n:]
333 333
        except Exception as e:
334
            logger.debug('broke out of main loop, error=%r', e)
334
            logger.debug("Broke out of main loop, error=%r", e)
335 335
            self.close()
336 336
            self._dispatch_error(e)
337 337

  

Also available in: Unified diff