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