summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-10-30 16:19:30 -0700
committerScott Maxwell <scott@codecobblers.com>2013-10-30 16:19:30 -0700
commit66cfa97cce92b1d60383d178887b18dddb999fc1 (patch)
treed4c70e30fb32d21a8b9f7cfcfbb62afbe1b5c067
parent3afc76a6b4c4b06193cdb4837ca1df1f3428fb20 (diff)
Fix imports
-rwxr-xr-xdemos/demo.py5
-rw-r--r--paramiko/__init__.py48
-rw-r--r--paramiko/_winapi.py6
-rw-r--r--paramiko/agent.py2
-rw-r--r--paramiko/ber.py3
-rw-r--r--paramiko/file.py2
-rw-r--r--paramiko/hostkeys.py34
-rw-r--r--paramiko/message.py2
-rw-r--r--paramiko/pipe.py1
-rw-r--r--paramiko/primes.py1
-rw-r--r--paramiko/proxy.py1
-rw-r--r--paramiko/transport.py2
-rwxr-xr-xtest.py26
-rw-r--r--tests/loop.py1
-rw-r--r--tests/stub_sftp.py2
-rw-r--r--tests/test_auth.py3
-rw-r--r--tests/test_buffered_pipe.py2
-rw-r--r--tests/test_client.py3
-rw-r--r--tests/test_kex.py1
-rw-r--r--tests/test_message.py1
-rw-r--r--tests/test_packetizer.py3
-rw-r--r--tests/test_pkey.py3
-rwxr-xr-xtests/test_sftp.py7
-rw-r--r--tests/test_sftp_big.py7
-rw-r--r--tests/test_transport.py4
-rw-r--r--tests/test_util.py4
-rw-r--r--tests/util.py1
27 files changed, 112 insertions, 63 deletions
diff --git a/demos/demo.py b/demos/demo.py
index cbd7730e..3890eda7 100755
--- a/demos/demo.py
+++ b/demos/demo.py
@@ -30,7 +30,10 @@ import time
import traceback
import paramiko
-import interactive
+try:
+ import interactive
+except ImportError:
+ from . import interactive
def agent_auth(transport, username):
diff --git a/paramiko/__init__.py b/paramiko/__init__.py
index 32ccfcdb..a12ee04c 100644
--- a/paramiko/__init__.py
+++ b/paramiko/__init__.py
@@ -62,32 +62,32 @@ __version_info__ = tuple([ int(d) for d in __version__.split(".") ])
__license__ = "GNU Lesser General Public License (LGPL)"
-from transport import SecurityOptions, Transport
-from client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
-from auth_handler import AuthHandler
-from channel import Channel, ChannelFile
-from ssh_exception import SSHException, PasswordRequiredException, \
+from paramiko.transport import SecurityOptions, Transport
+from paramiko.client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
+from paramiko.auth_handler import AuthHandler
+from paramiko.channel import Channel, ChannelFile
+from paramiko.ssh_exception import SSHException, PasswordRequiredException, \
BadAuthenticationType, ChannelException, BadHostKeyException, \
AuthenticationException, ProxyCommandFailure
-from server import ServerInterface, SubsystemHandler, InteractiveQuery
-from rsakey import RSAKey
-from dsskey import DSSKey
-from ecdsakey import ECDSAKey
-from sftp import SFTPError, BaseSFTP
-from sftp_client import SFTP, SFTPClient
-from sftp_server import SFTPServer
-from sftp_attr import SFTPAttributes
-from sftp_handle import SFTPHandle
-from sftp_si import SFTPServerInterface
-from sftp_file import SFTPFile
-from message import Message
-from packet import Packetizer
-from file import BufferedFile
-from agent import Agent, AgentKey
-from pkey import PKey
-from hostkeys import HostKeys
-from config import SSHConfig
-from proxy import ProxyCommand
+from paramiko.server import ServerInterface, SubsystemHandler, InteractiveQuery
+from paramiko.rsakey import RSAKey
+from paramiko.dsskey import DSSKey
+from paramiko.ecdsakey import ECDSAKey
+from paramiko.sftp import SFTPError, BaseSFTP
+from paramiko.sftp_client import SFTP, SFTPClient
+from paramiko.sftp_server import SFTPServer
+from paramiko.sftp_attr import SFTPAttributes
+from paramiko.sftp_handle import SFTPHandle
+from paramiko.sftp_si import SFTPServerInterface
+from paramiko.sftp_file import SFTPFile
+from paramiko.message import Message
+from paramiko.packet import Packetizer
+from paramiko.file import BufferedFile
+from paramiko.agent import Agent, AgentKey
+from paramiko.pkey import PKey
+from paramiko.hostkeys import HostKeys
+from paramiko.config import SSHConfig
+from paramiko.proxy import ProxyCommand
# fix module names for epydoc
for c in locals().values():
diff --git a/paramiko/_winapi.py b/paramiko/_winapi.py
index f141b005..43d97511 100644
--- a/paramiko/_winapi.py
+++ b/paramiko/_winapi.py
@@ -8,7 +8,11 @@ in jaraco.windows and asking the author to port the fixes back here.
import ctypes
import ctypes.wintypes
-import __builtin__
+from paramiko.py3compat import u
+try:
+ import builtins
+except ImportError:
+ import __builtin__ as builtins
######################
# jaraco.windows.error
diff --git a/paramiko/agent.py b/paramiko/agent.py
index 23a5a2e4..67bb0671 100644
--- a/paramiko/agent.py
+++ b/paramiko/agent.py
@@ -34,7 +34,7 @@ from paramiko.ssh_exception import SSHException
from paramiko.message import Message
from paramiko.pkey import PKey
from paramiko.channel import Channel
-from paramiko.common import io_sleep
+from paramiko.common import *
from paramiko.util import retry_on_signal
SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \
diff --git a/paramiko/ber.py b/paramiko/ber.py
index 3941581c..f3b4b37e 100644
--- a/paramiko/ber.py
+++ b/paramiko/ber.py
@@ -17,7 +17,8 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-import util
+import paramiko.util as util
+from paramiko.common import *
class BERException (Exception):
diff --git a/paramiko/file.py b/paramiko/file.py
index 5fd81cfe..d1779130 100644
--- a/paramiko/file.py
+++ b/paramiko/file.py
@@ -20,7 +20,7 @@
BufferedFile.
"""
-from cStringIO import StringIO
+from paramiko.common import *
class BufferedFile (object):
diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py
index 9bcf0d55..c0e58b0e 100644
--- a/paramiko/hostkeys.py
+++ b/paramiko/hostkeys.py
@@ -23,7 +23,10 @@ L{HostKeys}
import base64
import binascii
from Crypto.Hash import SHA, HMAC
-import UserDict
+try:
+ from collections import MutableMapping
+except ImportError:
+ from UserDict import DictMixin as MutableMapping
from paramiko.common import *
from paramiko.dsskey import DSSKey
@@ -109,7 +112,7 @@ class HostKeyEntry:
return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key)
-class HostKeys (UserDict.DictMixin):
+class HostKeys (MutableMapping):
"""
Representation of an openssh-style "known hosts" file. Host keys can be
read from one or more files, and then individual hosts can be looked up to
@@ -215,12 +218,26 @@ class HostKeys (UserDict.DictMixin):
@return: keys associated with this host (or C{None})
@rtype: dict(str, L{PKey})
"""
- class SubDict (UserDict.DictMixin):
+ class SubDict (MutableMapping):
def __init__(self, hostname, entries, hostkeys):
self._hostname = hostname
self._entries = entries
self._hostkeys = hostkeys
+ def __iter__(self):
+ for k in self.keys():
+ yield k
+
+ def __len__(self):
+ return len(self.keys())
+
+ def __delitem__(self, key):
+ for e in list(self._entries):
+ if e.key.get_name() == key:
+ self._entries.remove(e)
+ else:
+ raise KeyError(key)
+
def __getitem__(self, key):
for e in self._entries:
if e.key.get_name() == key:
@@ -280,6 +297,17 @@ class HostKeys (UserDict.DictMixin):
"""
self._entries = []
+ def __iter__(self):
+ for k in self.keys():
+ yield k
+
+ def __len__(self):
+ return len(self.keys())
+
+ def __delitem__(self, key):
+ k = self[key]
+ pass
+
def __getitem__(self, key):
ret = self.lookup(key)
if ret is None:
diff --git a/paramiko/message.py b/paramiko/message.py
index c0e8692b..d579a167 100644
--- a/paramiko/message.py
+++ b/paramiko/message.py
@@ -21,9 +21,9 @@ Implementation of an SSH2 "message".
"""
import struct
-import cStringIO
from paramiko import util
+from paramiko.common import *
class Message (object):
diff --git a/paramiko/pipe.py b/paramiko/pipe.py
index db43d549..e64547bd 100644
--- a/paramiko/pipe.py
+++ b/paramiko/pipe.py
@@ -27,6 +27,7 @@ will trigger as readable in select().
import sys
import os
import socket
+from paramiko.py3compat import b
def make_pipe ():
diff --git a/paramiko/primes.py b/paramiko/primes.py
index 9419cd6b..bf2b810c 100644
--- a/paramiko/primes.py
+++ b/paramiko/primes.py
@@ -24,6 +24,7 @@ from Crypto.Util import number
from paramiko import util
from paramiko.ssh_exception import SSHException
+from paramiko.common import *
def _generate_prime(bits, rng):
diff --git a/paramiko/proxy.py b/paramiko/proxy.py
index 218b76e2..a10feb01 100644
--- a/paramiko/proxy.py
+++ b/paramiko/proxy.py
@@ -21,6 +21,7 @@ L{ProxyCommand}.
"""
import os
+import sys
from shlex import split as shlsplit
import signal
from subprocess import Popen, PIPE
diff --git a/paramiko/transport.py b/paramiko/transport.py
index 3155d3f8..c6ab1272 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -79,7 +79,7 @@ class SecurityOptions (object):
C{ValueError} will be raised. If you try to assign something besides a
tuple to one of the fields, C{TypeError} will be raised.
"""
- __slots__ = [ 'ciphers', 'digests', 'key_types', 'kex', 'compression', '_transport' ]
+ #__slots__ = [ 'ciphers', 'digests', 'key_types', 'kex', 'compression', '_transport' ]
def __init__(self, transport):
self._transport = transport
diff --git a/test.py b/test.py
index 6702e53a..159794c5 100755
--- a/test.py
+++ b/test.py
@@ -32,19 +32,19 @@ import threading
sys.path.append('tests')
-from test_message import MessageTest
-from test_file import BufferedFileTest
-from test_buffered_pipe import BufferedPipeTest
-from test_util import UtilTest
-from test_hostkeys import HostKeysTest
-from test_pkey import KeyTest
-from test_kex import KexTest
-from test_packetizer import PacketizerTest
-from test_auth import AuthTest
-from test_transport import TransportTest
-from test_sftp import SFTPTest
-from test_sftp_big import BigSFTPTest
-from test_client import SSHClientTest
+from tests.test_message import MessageTest
+from tests.test_file import BufferedFileTest
+from tests.test_buffered_pipe import BufferedPipeTest
+from tests.test_util import UtilTest
+from tests.test_hostkeys import HostKeysTest
+from tests.test_pkey import KeyTest
+from tests.test_kex import KexTest
+from tests.test_packetizer import PacketizerTest
+from tests.test_auth import AuthTest
+from tests.test_transport import TransportTest
+from tests.test_sftp import SFTPTest
+from tests.test_sftp_big import BigSFTPTest
+from tests.test_client import SSHClientTest
default_host = 'localhost'
default_user = os.environ.get('USER', 'nobody')
diff --git a/tests/loop.py b/tests/loop.py
index 91c216d2..2f3f5dfc 100644
--- a/tests/loop.py
+++ b/tests/loop.py
@@ -21,6 +21,7 @@
"""
import threading, socket
+from paramiko.py3compat import *
class LoopSocket (object):
diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py
index 3021d816..e5f44543 100644
--- a/tests/stub_sftp.py
+++ b/tests/stub_sftp.py
@@ -21,8 +21,10 @@ A stub SFTP server for loopback SFTP testing.
"""
import os
+import sys
from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \
SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED
+from paramiko.common import *
class StubServer (ServerInterface):
diff --git a/tests/test_auth.py b/tests/test_auth.py
index 61fe63f4..1e247d70 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -29,7 +29,8 @@ from paramiko import Transport, ServerInterface, RSAKey, DSSKey, \
AuthenticationException
from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
-from loop import LoopSocket
+from tests.loop import LoopSocket
+from tests.util import test_path
class NullServer (ServerInterface):
diff --git a/tests/test_buffered_pipe.py b/tests/test_buffered_pipe.py
index 47ece936..04d665c4 100644
--- a/tests/test_buffered_pipe.py
+++ b/tests/test_buffered_pipe.py
@@ -26,7 +26,7 @@ import unittest
from paramiko.buffered_pipe import BufferedPipe, PipeTimeout
from paramiko import pipe
-from util import ParamikoTest
+from tests.util import ParamikoTest
def delay_thread(pipe):
diff --git a/tests/test_client.py b/tests/test_client.py
index e5352278..7d1e6729 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -20,13 +20,14 @@
Some unit tests for SSHClient.
"""
+import os
import socket
import threading
import time
import unittest
import weakref
from binascii import hexlify
-
+from tests.util import test_path
import paramiko
diff --git a/tests/test_kex.py b/tests/test_kex.py
index 39d2e17e..be8d7f01 100644
--- a/tests/test_kex.py
+++ b/tests/test_kex.py
@@ -26,6 +26,7 @@ import paramiko.util
from paramiko.kex_group1 import KexGroup1
from paramiko.kex_gex import KexGex
from paramiko import Message
+from paramiko.common import *
class FakeRng (object):
diff --git a/tests/test_message.py b/tests/test_message.py
index ad622a27..d0e604e3 100644
--- a/tests/test_message.py
+++ b/tests/test_message.py
@@ -22,6 +22,7 @@ Some unit tests for ssh protocol message blocks.
import unittest
from paramiko.message import Message
+from paramiko.common import *
class MessageTest (unittest.TestCase):
diff --git a/tests/test_packetizer.py b/tests/test_packetizer.py
index 1f5bec05..c39fc455 100644
--- a/tests/test_packetizer.py
+++ b/tests/test_packetizer.py
@@ -21,10 +21,11 @@ Some unit tests for the ssh2 protocol in Transport.
"""
import unittest
-from loop import LoopSocket
+from tests.loop import LoopSocket
from Crypto.Cipher import AES
from Crypto.Hash import SHA, HMAC
from paramiko import Message, Packetizer, util
+from paramiko.py3compat import byte_chr
class PacketizerTest (unittest.TestCase):
diff --git a/tests/test_pkey.py b/tests/test_pkey.py
index 8e8c4aa7..fe823a77 100644
--- a/tests/test_pkey.py
+++ b/tests/test_pkey.py
@@ -21,10 +21,9 @@ Some unit tests for public/private key objects.
"""
from binascii import hexlify, unhexlify
-import StringIO
import unittest
from paramiko import RSAKey, DSSKey, ECDSAKey, Message, util
-from paramiko.common import rng
+from paramiko.common import rng, StringIO, byte_chr
# from openssh's ssh-keygen
PUB_RSA = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA049W6geFpmsljTwfvI1UmKWWJPNFI74+vNKTk4dmzkQY2yAMs6FhlvhlI8ysU4oj71ZsRYMecHbBbxdN79+JRFVYTKaLqjwGENeTd+yv4q+V2PvZv3fLnzApI3l7EJCqhWwJUHJ1jAkZzqDx0tyOL4uoZpww3nmE0kb3y21tH4c='
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index cc512c18..3c1fcd52 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -31,11 +31,12 @@ import warnings
import sys
import threading
import unittest
-import StringIO
import paramiko
-from stub_sftp import StubServer, StubSFTPServer
-from loop import LoopSocket
+from paramiko.common import *
+from tests.stub_sftp import StubServer, StubSFTPServer
+from tests.loop import LoopSocket
+from tests.util import test_path
from paramiko.sftp_attr import SFTPAttributes
ARTICLE = '''
diff --git a/tests/test_sftp_big.py b/tests/test_sftp_big.py
index 04b15b0d..9a4ea311 100644
--- a/tests/test_sftp_big.py
+++ b/tests/test_sftp_big.py
@@ -33,9 +33,10 @@ import time
import unittest
import paramiko
-from stub_sftp import StubServer, StubSFTPServer
-from loop import LoopSocket
-from test_sftp import get_sftp
+from paramiko.common import *
+from tests.stub_sftp import StubServer, StubSFTPServer
+from tests.loop import LoopSocket
+from tests.test_sftp import get_sftp
FOLDER = os.environ.get('TEST_FOLDER', 'temp-testing000')
diff --git a/tests/test_transport.py b/tests/test_transport.py
index e8f7f366..ed8ebb42 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -35,8 +35,8 @@ from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
from paramiko.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST
from paramiko.message import Message
-from loop import LoopSocket
-from util import ParamikoTest
+from tests.loop import LoopSocket
+from tests.util import ParamikoTest, test_path
LONG_BANNER = """\
diff --git a/tests/test_util.py b/tests/test_util.py
index 12677a9b..12575f84 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -21,15 +21,15 @@ Some unit tests for utility functions.
"""
from binascii import hexlify
-import cStringIO
import errno
import os
import unittest
from Crypto.Hash import SHA
import paramiko.util
from paramiko.util import lookup_ssh_host_config as host_config
+from paramiko.py3compat import StringIO, byte_ord
-from util import ParamikoTest
+from tests.util import ParamikoTest
test_config_file = """\
Host *
diff --git a/tests/util.py b/tests/util.py
index 2e0be087..1b380b75 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -1,3 +1,4 @@
+import os
import unittest