diff options
author | Robey Pointer <robey@lag.net> | 2005-10-13 18:52:59 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2005-10-13 18:52:59 +0000 |
commit | 6eab0b3b4df096aa6b9421c8fe342078d182c523 (patch) | |
tree | a971bd201673ccfaa4f831308945d9dc670a1c40 | |
parent | 8bb5e65499661bc1e0556ccfe56c4317d70317cd (diff) |
[project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-65]
remove unnecessary shebangs, fix import lines to be explicit about imports from within paramiko, and a bit of whitespace cleanup
-rw-r--r-- | paramiko/agent.py | 12 | ||||
-rw-r--r-- | paramiko/auth_handler.py | 10 | ||||
-rw-r--r-- | paramiko/ber.py | 6 | ||||
-rw-r--r-- | paramiko/channel.py | 20 | ||||
-rw-r--r-- | paramiko/common.py | 6 | ||||
-rw-r--r-- | paramiko/dsskey.py | 16 | ||||
-rw-r--r-- | paramiko/file.py | 4 | ||||
-rw-r--r-- | paramiko/kex_gex.py | 10 | ||||
-rw-r--r-- | paramiko/kex_group1.py | 9 | ||||
-rw-r--r-- | paramiko/logging22.py | 5 | ||||
-rw-r--r-- | paramiko/message.py | 6 | ||||
-rw-r--r-- | paramiko/packet.py | 15 | ||||
-rw-r--r-- | paramiko/pipe.py | 2 | ||||
-rw-r--r-- | paramiko/pkey.py | 11 | ||||
-rw-r--r-- | paramiko/primes.py | 4 | ||||
-rw-r--r-- | paramiko/rsakey.py | 14 | ||||
-rw-r--r-- | paramiko/server.py | 6 | ||||
-rw-r--r-- | paramiko/sftp.py | 13 | ||||
-rw-r--r-- | paramiko/sftp_attr.py | 9 | ||||
-rw-r--r-- | paramiko/sftp_client.py | 6 | ||||
-rw-r--r-- | paramiko/sftp_file.py | 8 | ||||
-rw-r--r-- | paramiko/sftp_handle.py | 7 | ||||
-rw-r--r-- | paramiko/sftp_server.py | 18 | ||||
-rw-r--r-- | paramiko/sftp_si.py | 9 | ||||
-rw-r--r-- | paramiko/ssh_exception.py | 5 | ||||
-rw-r--r-- | paramiko/util.py | 14 |
26 files changed, 132 insertions, 113 deletions
diff --git a/paramiko/agent.py b/paramiko/agent.py index 7e32c79d..fcf9b64a 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -20,15 +20,19 @@ SSH Agent interface for Unix clients. """ -import os, socket, struct +import os +import socket +import struct + +from paramiko.ssh_exception import SSHException +from paramiko.message import Message +from paramiko.pkey import PKey -from ssh_exception import SSHException -from message import Message -from pkey import PKey SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \ SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15) + class Agent: """ Client interface for using private keys from an SSH agent running on the diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index f2ea0d86..87646894 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -25,11 +25,11 @@ import threading # this helps freezing utils import encodings.utf_8 -from common import * -import util -from message import Message -from ssh_exception import SSHException, BadAuthenticationType, PartialAuthentication -from server import InteractiveQuery +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ssh_exception import SSHException, BadAuthenticationType, PartialAuthentication +from paramiko.server import InteractiveQuery class AuthHandler (object): diff --git a/paramiko/ber.py b/paramiko/ber.py index a28b4a73..6a7823d8 100644 --- a/paramiko/ber.py +++ b/paramiko/ber.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -18,12 +16,14 @@ # along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -import struct, util +import struct +import util class BERException (Exception): pass + class BER(object): """ Robey's tiny little attempt at a BER decoder. diff --git a/paramiko/channel.py b/paramiko/channel.py index db85aacc..5edf4b3e 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -20,14 +20,18 @@ Abstraction for an SSH2 channel. """ -import sys, time, threading, socket, os +import sys +import time +import threading +import socket +import os -from common import * -import util -from message import Message -from ssh_exception import SSHException -from file import BufferedFile -import pipe +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ssh_exception import SSHException +from paramiko.file import BufferedFile +from paramiko import pipe class Channel (object): @@ -1105,8 +1109,6 @@ class Channel (object): return size - - class ChannelFile (BufferedFile): """ A file-like wrapper around L{Channel}. A ChannelFile is created by calling diff --git a/paramiko/common.py b/paramiko/common.py index 548013d6..360b804a 100644 --- a/paramiko/common.py +++ b/paramiko/common.py @@ -33,6 +33,7 @@ MSG_CHANNEL_OPEN, MSG_CHANNEL_OPEN_SUCCESS, MSG_CHANNEL_OPEN_FAILURE, \ MSG_CHANNEL_EOF, MSG_CHANNEL_CLOSE, MSG_CHANNEL_REQUEST, \ MSG_CHANNEL_SUCCESS, MSG_CHANNEL_FAILURE = range(90, 101) + # for debugging: MSG_NAMES = { MSG_DISCONNECT: 'disconnect', @@ -70,19 +71,19 @@ MSG_NAMES = { MSG_CHANNEL_FAILURE: 'channel-failure' } -# authentication request return codes: +# authentication request return codes: AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED = range(3) # channel request failed reasons: - (OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE) = range(0, 5) + CONNECTION_FAILED_CODE = { 1: 'Administratively prohibited', 2: 'Connect failed', @@ -95,7 +96,6 @@ DISCONNECT_SERVICE_NOT_AVAILABLE, DISCONNECT_AUTH_CANCELLED_BY_USER, \ DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 7, 13, 14 - from Crypto.Util.randpool import PersistentRandomPool, RandomPool # keep a crypto-strong PRNG nearby diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py index d7534ba9..6e94d814 100644 --- a/paramiko/dsskey.py +++ b/paramiko/dsskey.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -25,12 +23,13 @@ L{DSSKey} from Crypto.PublicKey import DSA from Crypto.Hash import SHA -from common import * -import util -from ssh_exception import SSHException -from message import Message -from ber import BER, BERException -from pkey import PKey +from paramiko.common import * +from paramiko import util +from paramiko.ssh_exception import SSHException +from paramiko.message import Message +from paramiko.ber import BER, BERException +from paramiko.pkey import PKey + class DSSKey (PKey): """ @@ -167,4 +166,3 @@ class DSSKey (PKey): self.y = keylist[4] self.x = keylist[5] self.size = util.bit_length(self.p) - diff --git a/paramiko/file.py b/paramiko/file.py index f066c4a8..c29e7c45 100644 --- a/paramiko/file.py +++ b/paramiko/file.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -24,6 +22,7 @@ BufferedFile. from cStringIO import StringIO + _FLAG_READ = 0x1 _FLAG_WRITE = 0x2 _FLAG_APPEND = 0x4 @@ -32,6 +31,7 @@ _FLAG_BUFFERED = 0x20 _FLAG_LINE_BUFFERED = 0x40 _FLAG_UNIVERSAL_NEWLINE = 0x80 + class BufferedFile (object): """ Reusable base class to implement python-style file buffering around a diff --git a/paramiko/kex_gex.py b/paramiko/kex_gex.py index e0974c1f..994d76cb 100644 --- a/paramiko/kex_gex.py +++ b/paramiko/kex_gex.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -27,10 +25,10 @@ client side, and a B{lot} more on the server side. from Crypto.Hash import SHA from Crypto.Util import number -from common import * -from message import Message -import util -from ssh_exception import SSHException +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ssh_exception import SSHException _MSG_KEXDH_GEX_GROUP, _MSG_KEXDH_GEX_INIT, _MSG_KEXDH_GEX_REPLY, _MSG_KEXDH_GEX_REQUEST = range(31, 35) diff --git a/paramiko/kex_group1.py b/paramiko/kex_group1.py index 33713685..a13cf3a0 100644 --- a/paramiko/kex_group1.py +++ b/paramiko/kex_group1.py @@ -23,10 +23,11 @@ Standard SSH key exchange ("kex" if you wanna sound cool). Diffie-Hellman of from Crypto.Hash import SHA -from common import * -import util -from message import Message -from ssh_exception import SSHException +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ssh_exception import SSHException + _MSG_KEXDH_INIT, _MSG_KEXDH_REPLY = range(30, 32) diff --git a/paramiko/logging22.py b/paramiko/logging22.py index 85f59471..e21b1548 100644 --- a/paramiko/logging22.py +++ b/paramiko/logging22.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -22,15 +20,18 @@ Stub out logging on python < 2.3. """ + DEBUG = 10 INFO = 20 WARNING = 30 ERROR = 40 CRITICAL = 50 + def getLogger(name): return _logger + class logger (object): def __init__(self): self.handlers = [ ] diff --git a/paramiko/message.py b/paramiko/message.py index e36d93a3..1d75a019 100644 --- a/paramiko/message.py +++ b/paramiko/message.py @@ -20,8 +20,10 @@ Implementation of an SSH2 "message". """ -import struct, cStringIO -import util +import struct +import cStringIO + +from paramiko import util class Message (object): diff --git a/paramiko/packet.py b/paramiko/packet.py index b7a2793f..6de9971f 100644 --- a/paramiko/packet.py +++ b/paramiko/packet.py @@ -20,12 +20,17 @@ Packetizer. """ -import select, socket, struct, threading, time +import select +import socket +import struct +import threading +import time from Crypto.Hash import HMAC -from common import * -from ssh_exception import SSHException -from message import Message -import util + +from paramiko.common import * +from paramiko import util +from paramiko.ssh_exception import SSHException +from paramiko.message import Message class Packetizer (object): diff --git a/paramiko/pipe.py b/paramiko/pipe.py index 332090e0..8c539877 100644 --- a/paramiko/pipe.py +++ b/paramiko/pipe.py @@ -67,7 +67,7 @@ class WindowsPipe (object): serv.bind(('127.0.0.1', 0)) serv.listen(1) - # need to save sockets in pipe_rsock/pipe_wsock so they don't get closed + # need to save sockets in _rsock/_wsock so they don't get closed self._rsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._rsock.connect(('127.0.0.1', serv.getsockname()[1])) diff --git a/paramiko/pkey.py b/paramiko/pkey.py index 79f56bc1..75db8e56 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -20,15 +20,16 @@ Common API for all public keys. """ -import os, base64 +import base64 +import os from Crypto.Hash import MD5 from Crypto.Cipher import DES3 -from common import * -from message import Message -from ssh_exception import SSHException, PasswordRequiredException -import util +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ssh_exception import SSHException, PasswordRequiredException class PKey (object): diff --git a/paramiko/primes.py b/paramiko/primes.py index a6998cd1..36773944 100644 --- a/paramiko/primes.py +++ b/paramiko/primes.py @@ -21,7 +21,8 @@ Utility functions for dealing with primes. """ from Crypto.Util import number -import util + +from paramiko import util def _generate_prime(bits, randpool): @@ -145,4 +146,3 @@ class ModulusPack (object): # now pick a random modulus of this bitsize n = _roll_random(self.randpool, len(self.pack[good])) return self.pack[good][n] - diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py index 7751b494..7e6b07e4 100644 --- a/paramiko/rsakey.py +++ b/paramiko/rsakey.py @@ -24,12 +24,13 @@ from Crypto.PublicKey import RSA from Crypto.Hash import SHA, MD5 from Crypto.Cipher import DES3 -from common import * -from message import Message -from ber import BER, BERException -import util -from pkey import PKey -from ssh_exception import SSHException +from paramiko.common import * +from paramiko import util +from paramiko.message import Message +from paramiko.ber import BER, BERException +from paramiko.pkey import PKey +from paramiko.ssh_exception import SSHException + class RSAKey (PKey): """ @@ -161,4 +162,3 @@ class RSAKey (PKey): self.p = keylist[4] self.q = keylist[5] self.size = util.bit_length(self.n) - diff --git a/paramiko/server.py b/paramiko/server.py index 859ae6ba..a0e39883 100644 --- a/paramiko/server.py +++ b/paramiko/server.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -23,8 +21,8 @@ L{ServerInterface} is an interface to override for server support. """ import threading -from common import * -import util +from paramiko.common import * +from paramiko import util class InteractiveQuery (object): diff --git a/paramiko/sftp.py b/paramiko/sftp.py index 78c204b7..58d71030 100644 --- a/paramiko/sftp.py +++ b/paramiko/sftp.py @@ -16,11 +16,14 @@ # along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -import struct, socket -from common import * -import util -from channel import Channel -from message import Message +import socket +import struct + +from paramiko.common import * +from paramiko import util +from paramiko.channel import Channel +from paramiko.message import Message + CMD_INIT, CMD_VERSION, CMD_OPEN, CMD_CLOSE, CMD_READ, CMD_WRITE, CMD_LSTAT, CMD_FSTAT, \ CMD_SETSTAT, CMD_FSETSTAT, CMD_OPENDIR, CMD_READDIR, CMD_REMOVE, CMD_MKDIR, \ diff --git a/paramiko/sftp_attr.py b/paramiko/sftp_attr.py index b2812c6d..05ebcf72 100644 --- a/paramiko/sftp_attr.py +++ b/paramiko/sftp_attr.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -18,9 +16,10 @@ # along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -import stat, time -from common import * -from sftp import * +import stat +import time +from paramiko.common import * +from paramiko.sftp import * class SFTPAttributes (object): diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index 9efad31a..06e402ea 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -21,9 +21,9 @@ Client-mode SFTP support. """ import os -from sftp import * -from sftp_attr import SFTPAttributes -from sftp_file import SFTPFile +from paramiko.sftp import * +from paramiko.sftp_attr import SFTPAttributes +from paramiko.sftp_file import SFTPFile def _to_unicode(s): diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 4fb0a4ba..477aec16 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -20,10 +20,10 @@ L{SFTPFile} """ -from common import * -from sftp import * -from file import BufferedFile -from sftp_attr import SFTPAttributes +from paramiko.common import * +from paramiko.sftp import * +from paramiko.file import BufferedFile +from paramiko.sftp_attr import SFTPAttributes class SFTPFile (BufferedFile): diff --git a/paramiko/sftp_handle.py b/paramiko/sftp_handle.py index fc615965..e1d93e9f 100644 --- a/paramiko/sftp_handle.py +++ b/paramiko/sftp_handle.py @@ -21,8 +21,9 @@ Abstraction of an SFTP file handle (for server mode). """ import os -from common import * -from sftp import * + +from paramiko.common import * +from paramiko.sftp import * class SFTPHandle (object): @@ -184,4 +185,4 @@ class SFTPHandle (object): self.__name = name -from sftp_server import SFTPServer +from paramiko.sftp_server import SFTPServer diff --git a/paramiko/sftp_server.py b/paramiko/sftp_server.py index 13e05c0b..9cc05508 100644 --- a/paramiko/sftp_server.py +++ b/paramiko/sftp_server.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -22,13 +20,15 @@ Server-mode SFTP support. """ -import os, errno +import os +import errno + from Crypto.Hash import MD5, SHA -from common import * -from server import SubsystemHandler -from sftp import * -from sftp_si import * -from sftp_attr import * +from paramiko.common import * +from paramiko.server import SubsystemHandler +from paramiko.sftp import * +from paramiko.sftp_si import * +from paramiko.sftp_attr import * # known hash algorithms for the "check-file" extension @@ -417,4 +417,4 @@ class SFTPServer (BaseSFTP, SubsystemHandler): self._send_status(request_number, SFTP_OP_UNSUPPORTED) -from sftp_handle import SFTPHandle +from paramiko.sftp_handle import SFTPHandle diff --git a/paramiko/sftp_si.py b/paramiko/sftp_si.py index 262cc721..16005d42 100644 --- a/paramiko/sftp_si.py +++ b/paramiko/sftp_si.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -23,8 +21,10 @@ L{SFTPServerInterface} is an interface to override for SFTP server support. """ import os -from common import * -from sftp import * + +from paramiko.common import * +from paramiko.sftp import * + class SFTPServerInterface (object): """ @@ -301,4 +301,3 @@ class SFTPServerInterface (object): @rtype: int """ return SFTP_OP_UNSUPPORTED - diff --git a/paramiko/ssh_exception.py b/paramiko/ssh_exception.py index 031623e2..900d4a0b 100644 --- a/paramiko/ssh_exception.py +++ b/paramiko/ssh_exception.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # # This file is part of paramiko. @@ -29,12 +27,14 @@ class SSHException (Exception): """ pass + class PasswordRequiredException (SSHException): """ Exception raised when a password is needed to unlock a private key file. """ pass + class BadAuthenticationType (SSHException): """ Exception raised when an authentication type (like password) is used, but @@ -57,6 +57,7 @@ class BadAuthenticationType (SSHException): def __str__(self): return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types + class PartialAuthentication (SSHException): """ An internal exception thrown in the case of partial authentication. diff --git a/paramiko/util.py b/paramiko/util.py index d0d2c0de..cf90033c 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -16,14 +16,19 @@ # along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -from __future__ import generators - """ Useful functions used by the rest of paramiko. """ -import sys, struct, traceback, threading -from common import * +from __future__ import generators + +import sys +import struct +import traceback +import threading + +from paramiko.common import * + # Change by RogerB - python < 2.3 doesn't have enumerate so we implement it if sys.version_info < (2,3): @@ -36,6 +41,7 @@ if sys.version_info < (2,3): yield (count, item) count += 1 + def inflate_long(s, always_positive=False): "turns a normalized byte string into a long-int (adapted from Crypto.Util.number)" out = 0L |