[Python 3]: Wrapped unicode and string type checks in six's type definitions. Absolute import fixes for Windows agents.
This commit is contained in:
parent
387f243c1d
commit
3c33c763a7
|
@ -118,7 +118,7 @@ class MemoryMap(object):
|
|||
FILE_MAP_WRITE = 0x2
|
||||
filemap = ctypes.windll.kernel32.CreateFileMappingW(
|
||||
INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length,
|
||||
unicode(self.name))
|
||||
builtins.unicode(self.name))
|
||||
handle_nonzero_success(filemap)
|
||||
if filemap == INVALID_HANDLE_VALUE:
|
||||
raise Exception("Failed to create file mapping")
|
||||
|
|
|
@ -215,7 +215,7 @@ class AgentClientProxy(object):
|
|||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
from paramiko import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
|
@ -334,7 +334,7 @@ class Agent(AgentSSH):
|
|||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
from paramiko import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
|
|
|
@ -25,6 +25,7 @@ import weakref
|
|||
|
||||
# this helps freezing utils
|
||||
import encodings.utf_8
|
||||
import six
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
|
@ -198,7 +199,7 @@ class AuthHandler (object):
|
|||
if self.auth_method == 'password':
|
||||
m.add_boolean(False)
|
||||
password = self.password
|
||||
if isinstance(password, unicode):
|
||||
if isinstance(password, six.text_type):
|
||||
password = password.encode('UTF-8')
|
||||
m.add_string(password)
|
||||
elif self.auth_method == 'publickey':
|
||||
|
|
|
@ -25,6 +25,7 @@ import getpass
|
|||
import os
|
||||
import socket
|
||||
import warnings
|
||||
import six
|
||||
|
||||
from paramiko.agent import Agent
|
||||
from paramiko.common import *
|
||||
|
@ -335,7 +336,7 @@ class SSHClient (object):
|
|||
|
||||
if key_filename is None:
|
||||
key_filenames = []
|
||||
elif isinstance(key_filename, (str, unicode)):
|
||||
elif isinstance(key_filename, (six.binary_type, six.text_type)):
|
||||
key_filenames = [ key_filename ]
|
||||
else:
|
||||
key_filenames = key_filename
|
||||
|
|
|
@ -21,6 +21,8 @@ L{ServerInterface} is an interface to override for server support.
|
|||
"""
|
||||
|
||||
import threading
|
||||
import six
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
|
||||
|
@ -48,7 +50,7 @@ class InteractiveQuery (object):
|
|||
self.instructions = instructions
|
||||
self.prompts = []
|
||||
for x in prompts:
|
||||
if (type(x) is str) or (type(x) is unicode):
|
||||
if isinstance(x, (six.binary_type, six.text_type)):
|
||||
self.add_prompt(x)
|
||||
else:
|
||||
self.add_prompt(x[0], x[1])
|
||||
|
|
|
@ -373,7 +373,7 @@ class SFTPClient (BaseSFTP):
|
|||
"""
|
||||
dest = self._adjust_cwd(dest)
|
||||
self._log(DEBUG, 'symlink(%r, %r)' % (source, dest))
|
||||
if type(source) is unicode:
|
||||
if isinstance(source, six.text_type):
|
||||
source = source.encode('utf-8')
|
||||
self._request(CMD_SYMLINK, source, dest)
|
||||
|
||||
|
@ -774,7 +774,7 @@ class SFTPClient (BaseSFTP):
|
|||
Return an adjusted path if we're emulating a "current working
|
||||
directory" for the server.
|
||||
"""
|
||||
if type(path) is unicode:
|
||||
if isinstance(path, six.text_type):
|
||||
path = path.encode('utf-8')
|
||||
if self._cwd is None:
|
||||
return path
|
||||
|
|
|
@ -280,7 +280,7 @@ class Transport (threading.Thread):
|
|||
@param sock: a socket or socket-like object to create the session over.
|
||||
@type sock: socket
|
||||
"""
|
||||
if isinstance(sock, (str, unicode)):
|
||||
if isinstance(sock, (six.binary_type, six.text_type)):
|
||||
# convert "host:port" into (host, port)
|
||||
hl = sock.split(':', 1)
|
||||
if len(hl) == 1:
|
||||
|
|
Loading…
Reference in New Issue