Fix imports

This commit is contained in:
Scott Maxwell 2013-10-30 16:19:30 -07:00
parent 3afc76a6b4
commit 66cfa97cce
27 changed files with 112 additions and 63 deletions

View File

@ -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):

View File

@ -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():

View File

@ -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

View File

@ -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, \

View File

@ -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):

View File

@ -20,7 +20,7 @@
BufferedFile.
"""
from cStringIO import StringIO
from paramiko.common import *
class BufferedFile (object):

View File

@ -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:

View File

@ -21,9 +21,9 @@ Implementation of an SSH2 "message".
"""
import struct
import cStringIO
from paramiko import util
from paramiko.common import *
class Message (object):

View File

@ -27,6 +27,7 @@ will trigger as readable in select().
import sys
import os
import socket
from paramiko.py3compat import b
def make_pipe ():

View File

@ -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):

View File

@ -21,6 +21,7 @@ L{ProxyCommand}.
"""
import os
import sys
from shlex import split as shlsplit
import signal
from subprocess import Popen, PIPE

View File

@ -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

26
test.py
View File

@ -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')

View File

@ -21,6 +21,7 @@
"""
import threading, socket
from paramiko.py3compat import *
class LoopSocket (object):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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='

View File

@ -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 = '''

View File

@ -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')

View File

@ -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 = """\

View File

@ -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 *

View File

@ -1,3 +1,4 @@
import os
import unittest