[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
This commit is contained in:
Robey Pointer 2005-10-13 18:52:59 +00:00
parent 8bb5e65499
commit 6eab0b3b4d
26 changed files with 132 additions and 113 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 = [ ]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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