[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. 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_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \
SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15) SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15)
class Agent: class Agent:
""" """
Client interface for using private keys from an SSH agent running on the 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 # this helps freezing utils
import encodings.utf_8 import encodings.utf_8
from common import * from paramiko.common import *
import util from paramiko import util
from message import Message from paramiko.message import Message
from ssh_exception import SSHException, BadAuthenticationType, PartialAuthentication from paramiko.ssh_exception import SSHException, BadAuthenticationType, PartialAuthentication
from server import InteractiveQuery from paramiko.server import InteractiveQuery
class AuthHandler (object): class AuthHandler (object):

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
# Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -18,12 +16,14 @@
# along with Paramiko; if not, write to the Free Software Foundation, Inc., # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
import struct, util import struct
import util
class BERException (Exception): class BERException (Exception):
pass pass
class BER(object): class BER(object):
""" """
Robey's tiny little attempt at a BER decoder. Robey's tiny little attempt at a BER decoder.

View File

@ -20,14 +20,18 @@
Abstraction for an SSH2 channel. Abstraction for an SSH2 channel.
""" """
import sys, time, threading, socket, os import sys
import time
import threading
import socket
import os
from common import * from paramiko.common import *
import util from paramiko import util
from message import Message from paramiko.message import Message
from ssh_exception import SSHException from paramiko.ssh_exception import SSHException
from file import BufferedFile from paramiko.file import BufferedFile
import pipe from paramiko import pipe
class Channel (object): class Channel (object):
@ -1105,8 +1109,6 @@ class Channel (object):
return size return size
class ChannelFile (BufferedFile): class ChannelFile (BufferedFile):
""" """
A file-like wrapper around L{Channel}. A ChannelFile is created by calling 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_EOF, MSG_CHANNEL_CLOSE, MSG_CHANNEL_REQUEST, \
MSG_CHANNEL_SUCCESS, MSG_CHANNEL_FAILURE = range(90, 101) MSG_CHANNEL_SUCCESS, MSG_CHANNEL_FAILURE = range(90, 101)
# for debugging: # for debugging:
MSG_NAMES = { MSG_NAMES = {
MSG_DISCONNECT: 'disconnect', MSG_DISCONNECT: 'disconnect',
@ -70,19 +71,19 @@ MSG_NAMES = {
MSG_CHANNEL_FAILURE: 'channel-failure' MSG_CHANNEL_FAILURE: 'channel-failure'
} }
# authentication request return codes:
# authentication request return codes:
AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED = range(3) AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED = range(3)
# channel request failed reasons: # channel request failed reasons:
(OPEN_SUCCEEDED, (OPEN_SUCCEEDED,
OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED,
OPEN_FAILED_CONNECT_FAILED, OPEN_FAILED_CONNECT_FAILED,
OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_UNKNOWN_CHANNEL_TYPE,
OPEN_FAILED_RESOURCE_SHORTAGE) = range(0, 5) OPEN_FAILED_RESOURCE_SHORTAGE) = range(0, 5)
CONNECTION_FAILED_CODE = { CONNECTION_FAILED_CODE = {
1: 'Administratively prohibited', 1: 'Administratively prohibited',
2: 'Connect failed', 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 DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 7, 13, 14
from Crypto.Util.randpool import PersistentRandomPool, RandomPool from Crypto.Util.randpool import PersistentRandomPool, RandomPool
# keep a crypto-strong PRNG nearby # keep a crypto-strong PRNG nearby

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
# Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -25,12 +23,13 @@ L{DSSKey}
from Crypto.PublicKey import DSA from Crypto.PublicKey import DSA
from Crypto.Hash import SHA from Crypto.Hash import SHA
from common import * from paramiko.common import *
import util from paramiko import util
from ssh_exception import SSHException from paramiko.ssh_exception import SSHException
from message import Message from paramiko.message import Message
from ber import BER, BERException from paramiko.ber import BER, BERException
from pkey import PKey from paramiko.pkey import PKey
class DSSKey (PKey): class DSSKey (PKey):
""" """
@ -167,4 +166,3 @@ class DSSKey (PKey):
self.y = keylist[4] self.y = keylist[4]
self.x = keylist[5] self.x = keylist[5]
self.size = util.bit_length(self.p) 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -24,6 +22,7 @@ BufferedFile.
from cStringIO import StringIO from cStringIO import StringIO
_FLAG_READ = 0x1 _FLAG_READ = 0x1
_FLAG_WRITE = 0x2 _FLAG_WRITE = 0x2
_FLAG_APPEND = 0x4 _FLAG_APPEND = 0x4
@ -32,6 +31,7 @@ _FLAG_BUFFERED = 0x20
_FLAG_LINE_BUFFERED = 0x40 _FLAG_LINE_BUFFERED = 0x40
_FLAG_UNIVERSAL_NEWLINE = 0x80 _FLAG_UNIVERSAL_NEWLINE = 0x80
class BufferedFile (object): class BufferedFile (object):
""" """
Reusable base class to implement python-style file buffering around a 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # 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.Hash import SHA
from Crypto.Util import number from Crypto.Util import number
from common import * from paramiko.common import *
from message import Message from paramiko import util
import util from paramiko.message import Message
from ssh_exception import SSHException 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) _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 Crypto.Hash import SHA
from common import * from paramiko.common import *
import util from paramiko import util
from message import Message from paramiko.message import Message
from ssh_exception import SSHException from paramiko.ssh_exception import SSHException
_MSG_KEXDH_INIT, _MSG_KEXDH_REPLY = range(30, 32) _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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -22,15 +20,18 @@
Stub out logging on python < 2.3. Stub out logging on python < 2.3.
""" """
DEBUG = 10 DEBUG = 10
INFO = 20 INFO = 20
WARNING = 30 WARNING = 30
ERROR = 40 ERROR = 40
CRITICAL = 50 CRITICAL = 50
def getLogger(name): def getLogger(name):
return _logger return _logger
class logger (object): class logger (object):
def __init__(self): def __init__(self):
self.handlers = [ ] self.handlers = [ ]

View File

@ -20,8 +20,10 @@
Implementation of an SSH2 "message". Implementation of an SSH2 "message".
""" """
import struct, cStringIO import struct
import util import cStringIO
from paramiko import util
class Message (object): class Message (object):

View File

@ -20,12 +20,17 @@
Packetizer. Packetizer.
""" """
import select, socket, struct, threading, time import select
import socket
import struct
import threading
import time
from Crypto.Hash import HMAC from Crypto.Hash import HMAC
from common import *
from ssh_exception import SSHException from paramiko.common import *
from message import Message from paramiko import util
import util from paramiko.ssh_exception import SSHException
from paramiko.message import Message
class Packetizer (object): class Packetizer (object):

View File

@ -67,7 +67,7 @@ class WindowsPipe (object):
serv.bind(('127.0.0.1', 0)) serv.bind(('127.0.0.1', 0))
serv.listen(1) 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 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._rsock.connect(('127.0.0.1', serv.getsockname()[1])) self._rsock.connect(('127.0.0.1', serv.getsockname()[1]))

View File

@ -20,15 +20,16 @@
Common API for all public keys. Common API for all public keys.
""" """
import os, base64 import base64
import os
from Crypto.Hash import MD5 from Crypto.Hash import MD5
from Crypto.Cipher import DES3 from Crypto.Cipher import DES3
from common import * from paramiko.common import *
from message import Message from paramiko import util
from ssh_exception import SSHException, PasswordRequiredException from paramiko.message import Message
import util from paramiko.ssh_exception import SSHException, PasswordRequiredException
class PKey (object): class PKey (object):

View File

@ -21,7 +21,8 @@ Utility functions for dealing with primes.
""" """
from Crypto.Util import number from Crypto.Util import number
import util
from paramiko import util
def _generate_prime(bits, randpool): def _generate_prime(bits, randpool):
@ -145,4 +146,3 @@ class ModulusPack (object):
# now pick a random modulus of this bitsize # now pick a random modulus of this bitsize
n = _roll_random(self.randpool, len(self.pack[good])) n = _roll_random(self.randpool, len(self.pack[good]))
return self.pack[good][n] return self.pack[good][n]

View File

@ -24,12 +24,13 @@ from Crypto.PublicKey import RSA
from Crypto.Hash import SHA, MD5 from Crypto.Hash import SHA, MD5
from Crypto.Cipher import DES3 from Crypto.Cipher import DES3
from common import * from paramiko.common import *
from message import Message from paramiko import util
from ber import BER, BERException from paramiko.message import Message
import util from paramiko.ber import BER, BERException
from pkey import PKey from paramiko.pkey import PKey
from ssh_exception import SSHException from paramiko.ssh_exception import SSHException
class RSAKey (PKey): class RSAKey (PKey):
""" """
@ -161,4 +162,3 @@ class RSAKey (PKey):
self.p = keylist[4] self.p = keylist[4]
self.q = keylist[5] self.q = keylist[5]
self.size = util.bit_length(self.n) 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -23,8 +21,8 @@ L{ServerInterface} is an interface to override for server support.
""" """
import threading import threading
from common import * from paramiko.common import *
import util from paramiko import util
class InteractiveQuery (object): class InteractiveQuery (object):

View File

@ -16,11 +16,14 @@
# along with Paramiko; if not, write to the Free Software Foundation, Inc., # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
import struct, socket import socket
from common import * import struct
import util
from channel import Channel from paramiko.common import *
from message import Message 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_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, \ 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -18,9 +16,10 @@
# along with Paramiko; if not, write to the Free Software Foundation, Inc., # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
import stat, time import stat
from common import * import time
from sftp import * from paramiko.common import *
from paramiko.sftp import *
class SFTPAttributes (object): class SFTPAttributes (object):

View File

@ -21,9 +21,9 @@ Client-mode SFTP support.
""" """
import os import os
from sftp import * from paramiko.sftp import *
from sftp_attr import SFTPAttributes from paramiko.sftp_attr import SFTPAttributes
from sftp_file import SFTPFile from paramiko.sftp_file import SFTPFile
def _to_unicode(s): def _to_unicode(s):

View File

@ -20,10 +20,10 @@
L{SFTPFile} L{SFTPFile}
""" """
from common import * from paramiko.common import *
from sftp import * from paramiko.sftp import *
from file import BufferedFile from paramiko.file import BufferedFile
from sftp_attr import SFTPAttributes from paramiko.sftp_attr import SFTPAttributes
class SFTPFile (BufferedFile): class SFTPFile (BufferedFile):

View File

@ -21,8 +21,9 @@ Abstraction of an SFTP file handle (for server mode).
""" """
import os import os
from common import *
from sftp import * from paramiko.common import *
from paramiko.sftp import *
class SFTPHandle (object): class SFTPHandle (object):
@ -184,4 +185,4 @@ class SFTPHandle (object):
self.__name = name 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -22,13 +20,15 @@
Server-mode SFTP support. Server-mode SFTP support.
""" """
import os, errno import os
import errno
from Crypto.Hash import MD5, SHA from Crypto.Hash import MD5, SHA
from common import * from paramiko.common import *
from server import SubsystemHandler from paramiko.server import SubsystemHandler
from sftp import * from paramiko.sftp import *
from sftp_si import * from paramiko.sftp_si import *
from sftp_attr import * from paramiko.sftp_attr import *
# known hash algorithms for the "check-file" extension # known hash algorithms for the "check-file" extension
@ -417,4 +417,4 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
self._send_status(request_number, SFTP_OP_UNSUPPORTED) 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> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -23,8 +21,10 @@ L{SFTPServerInterface} is an interface to override for SFTP server support.
""" """
import os import os
from common import *
from sftp import * from paramiko.common import *
from paramiko.sftp import *
class SFTPServerInterface (object): class SFTPServerInterface (object):
""" """
@ -301,4 +301,3 @@ class SFTPServerInterface (object):
@rtype: int @rtype: int
""" """
return SFTP_OP_UNSUPPORTED return SFTP_OP_UNSUPPORTED

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
# Copyright (C) 2003-2005 Robey Pointer <robey@lag.net> # Copyright (C) 2003-2005 Robey Pointer <robey@lag.net>
# #
# This file is part of paramiko. # This file is part of paramiko.
@ -29,12 +27,14 @@ class SSHException (Exception):
""" """
pass pass
class PasswordRequiredException (SSHException): class PasswordRequiredException (SSHException):
""" """
Exception raised when a password is needed to unlock a private key file. Exception raised when a password is needed to unlock a private key file.
""" """
pass pass
class BadAuthenticationType (SSHException): class BadAuthenticationType (SSHException):
""" """
Exception raised when an authentication type (like password) is used, but Exception raised when an authentication type (like password) is used, but
@ -57,6 +57,7 @@ class BadAuthenticationType (SSHException):
def __str__(self): def __str__(self):
return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types
class PartialAuthentication (SSHException): class PartialAuthentication (SSHException):
""" """
An internal exception thrown in the case of partial authentication. 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., # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
from __future__ import generators
""" """
Useful functions used by the rest of paramiko. Useful functions used by the rest of paramiko.
""" """
import sys, struct, traceback, threading from __future__ import generators
from common import *
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 # Change by RogerB - python < 2.3 doesn't have enumerate so we implement it
if sys.version_info < (2,3): if sys.version_info < (2,3):
@ -36,6 +41,7 @@ if sys.version_info < (2,3):
yield (count, item) yield (count, item)
count += 1 count += 1
def inflate_long(s, always_positive=False): def inflate_long(s, always_positive=False):
"turns a normalized byte string into a long-int (adapted from Crypto.Util.number)" "turns a normalized byte string into a long-int (adapted from Crypto.Util.number)"
out = 0L out = 0L