[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-103]
rename sftp constants replace oddly named sftp constants (FX_OK for example) with names that make a bit more sense when sober (SFTP_OK).
This commit is contained in:
parent
0ab2735dd4
commit
1c32fcd99a
|
@ -68,7 +68,6 @@ __license__ = "GNU Lesser General Public License (LGPL)"
|
||||||
|
|
||||||
import transport, auth_transport, channel, rsakey, dsskey, message, ssh_exception, file
|
import transport, auth_transport, channel, rsakey, dsskey, message, ssh_exception, file
|
||||||
import sftp, sftp_client, sftp_attr, sftp_file
|
import sftp, sftp_client, sftp_attr, sftp_file
|
||||||
# import sftp_server, sftp_si
|
|
||||||
|
|
||||||
randpool = transport.randpool
|
randpool = transport.randpool
|
||||||
Transport = auth_transport.Transport
|
Transport = auth_transport.Transport
|
||||||
|
@ -80,10 +79,8 @@ Message = message.Message
|
||||||
PasswordRequiredException = ssh_exception.PasswordRequiredException
|
PasswordRequiredException = ssh_exception.PasswordRequiredException
|
||||||
SFTP = sftp_client.SFTP
|
SFTP = sftp_client.SFTP
|
||||||
SFTPClient = sftp_client.SFTPClient
|
SFTPClient = sftp_client.SFTPClient
|
||||||
# SFTPServer = sftp_server.SFTPServer
|
|
||||||
SFTPError = sftp_client.SFTPError
|
SFTPError = sftp_client.SFTPError
|
||||||
SFTPAttributes = sftp_attr.SFTPAttributes
|
SFTPAttributes = sftp_attr.SFTPAttributes
|
||||||
# SFTPServerInterface = sftp_si.SFTPServerInterface
|
|
||||||
ServerInterface = server.ServerInterface
|
ServerInterface = server.ServerInterface
|
||||||
SubsystemHandler = server.SubsystemHandler
|
SubsystemHandler = server.SubsystemHandler
|
||||||
SecurityOptions = transport.SecurityOptions
|
SecurityOptions = transport.SecurityOptions
|
||||||
|
@ -93,8 +90,8 @@ from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
|
||||||
OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, \
|
OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, \
|
||||||
OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE
|
OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE
|
||||||
|
|
||||||
from sftp import FX_OK, FX_EOF, FX_NO_SUCH_FILE, FX_PERMISSION_DENIED, FX_FAILURE, \
|
from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
|
||||||
FX_BAD_MESSAGE, FX_NO_CONNECTION, FX_CONNECTION_LOST, FX_OP_UNSUPPORTED
|
SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED
|
||||||
|
|
||||||
__all__ = [ 'Transport',
|
__all__ = [ 'Transport',
|
||||||
'SecurityOptions',
|
'SecurityOptions',
|
||||||
|
@ -107,10 +104,8 @@ __all__ = [ 'Transport',
|
||||||
'PasswordRequiredException',
|
'PasswordRequiredException',
|
||||||
'SFTP',
|
'SFTP',
|
||||||
'SFTPClient',
|
'SFTPClient',
|
||||||
# 'SFTPServer',
|
|
||||||
'SFTPError',
|
'SFTPError',
|
||||||
'SFTPAttributes',
|
'SFTPAttributes',
|
||||||
# 'SFTPServerInterface',
|
|
||||||
'ServerInterface',
|
'ServerInterface',
|
||||||
'BufferedFile',
|
'BufferedFile',
|
||||||
'transport',
|
'transport',
|
||||||
|
@ -122,10 +117,8 @@ __all__ = [ 'Transport',
|
||||||
'message',
|
'message',
|
||||||
'ssh_exception',
|
'ssh_exception',
|
||||||
'sftp_client',
|
'sftp_client',
|
||||||
# 'sftp_server',
|
|
||||||
'sftp_attr',
|
'sftp_attr',
|
||||||
'sftp_file',
|
'sftp_file',
|
||||||
# 'sftp_si',
|
|
||||||
'server',
|
'server',
|
||||||
'file',
|
'file',
|
||||||
'util' ]
|
'util' ]
|
||||||
|
|
|
@ -31,30 +31,62 @@ CMD_INIT, CMD_VERSION, CMD_OPEN, CMD_CLOSE, CMD_READ, CMD_WRITE, CMD_LSTAT, CMD_
|
||||||
CMD_STATUS, CMD_HANDLE, CMD_DATA, CMD_NAME, CMD_ATTRS = range(101, 106)
|
CMD_STATUS, CMD_HANDLE, CMD_DATA, CMD_NAME, CMD_ATTRS = range(101, 106)
|
||||||
CMD_EXTENDED, CMD_EXTENDED_REPLY = range(200, 202)
|
CMD_EXTENDED, CMD_EXTENDED_REPLY = range(200, 202)
|
||||||
|
|
||||||
FX_OK = 0
|
SFTP_OK = 0
|
||||||
FX_EOF, FX_NO_SUCH_FILE, FX_PERMISSION_DENIED, FX_FAILURE, FX_BAD_MESSAGE, \
|
SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, SFTP_BAD_MESSAGE, \
|
||||||
FX_NO_CONNECTION, FX_CONNECTION_LOST, FX_OP_UNSUPPORTED = range(1, 9)
|
SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED = range(1, 9)
|
||||||
|
|
||||||
FX_DESC = [ 'Success',
|
SFTP_DESC = [ 'Success',
|
||||||
'End of file',
|
'End of file',
|
||||||
'No such file',
|
'No such file',
|
||||||
'Permission denied',
|
'Permission denied',
|
||||||
'Failure',
|
'Failure',
|
||||||
'Bad message',
|
'Bad message',
|
||||||
'No connection',
|
'No connection',
|
||||||
'Connection lost',
|
'Connection lost',
|
||||||
'Operation unsupported' ]
|
'Operation unsupported' ]
|
||||||
|
|
||||||
FXF_READ = 0x1
|
SFTP_FLAG_READ = 0x1
|
||||||
FXF_WRITE = 0x2
|
SFTP_FLAG_WRITE = 0x2
|
||||||
FXF_APPEND = 0x4
|
SFTP_FLAG_APPEND = 0x4
|
||||||
FXF_CREATE = 0x8
|
SFTP_FLAG_CREATE = 0x8
|
||||||
FXF_TRUNC = 0x10
|
SFTP_FLAG_TRUNC = 0x10
|
||||||
FXF_EXCL = 0x20
|
SFTP_FLAG_EXCL = 0x20
|
||||||
|
|
||||||
_VERSION = 3
|
_VERSION = 3
|
||||||
|
|
||||||
|
|
||||||
|
# for debugging
|
||||||
|
CMD_NAMES = {
|
||||||
|
CMD_INIT: 'init',
|
||||||
|
CMD_VERSION: 'version',
|
||||||
|
CMD_OPEN: 'open',
|
||||||
|
CMD_CLOSE: 'close',
|
||||||
|
CMD_READ: 'read',
|
||||||
|
CMD_WRITE: 'write',
|
||||||
|
CMD_LSTAT: 'lstat',
|
||||||
|
CMD_FSTAT: 'fstat',
|
||||||
|
CMD_SETSTAT: 'setstat',
|
||||||
|
CMD_FSETSTAT: 'fsetstat',
|
||||||
|
CMD_OPENDIR: 'opendir',
|
||||||
|
CMD_READDIR: 'readdir',
|
||||||
|
CMD_REMOVE: 'remove',
|
||||||
|
CMD_MKDIR: 'mkdir',
|
||||||
|
CMD_RMDIR: 'rmdir',
|
||||||
|
CMD_REALPATH: 'realpath',
|
||||||
|
CMD_STAT: 'stat',
|
||||||
|
CMD_RENAME: 'rename',
|
||||||
|
CMD_READLINK: 'readlink',
|
||||||
|
CMD_SYMLINK: 'symlink',
|
||||||
|
CMD_STATUS: 'status',
|
||||||
|
CMD_HANDLE: 'handle',
|
||||||
|
CMD_DATA: 'data',
|
||||||
|
CMD_NAME: 'name',
|
||||||
|
CMD_ATTRS: 'attrs',
|
||||||
|
CMD_EXTENDED: 'extended',
|
||||||
|
CMD_EXTENDED_REPLY: 'extended_reply'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class SFTPError (Exception):
|
class SFTPError (Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -134,13 +134,13 @@ class SFTPClient (BaseSFTP):
|
||||||
"""
|
"""
|
||||||
imode = 0
|
imode = 0
|
||||||
if ('r' in mode) or ('+' in mode):
|
if ('r' in mode) or ('+' in mode):
|
||||||
imode |= FXF_READ
|
imode |= SFTP_FLAG_READ
|
||||||
if ('w' in mode) or ('+' in mode):
|
if ('w' in mode) or ('+' in mode):
|
||||||
imode |= FXF_WRITE
|
imode |= SFTP_FLAG_WRITE
|
||||||
if ('w' in mode):
|
if ('w' in mode):
|
||||||
imode |= FXF_CREATE | FXF_TRUNC
|
imode |= SFTP_FLAG_CREATE | SFTP_FLAG_TRUNC
|
||||||
if ('a' in mode):
|
if ('a' in mode):
|
||||||
imode |= FXF_APPEND
|
imode |= SFTP_FLAG_APPEND
|
||||||
attrblock = SFTPAttributes()
|
attrblock = SFTPAttributes()
|
||||||
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
|
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
|
||||||
if t != CMD_HANDLE:
|
if t != CMD_HANDLE:
|
||||||
|
@ -382,9 +382,9 @@ class SFTPClient (BaseSFTP):
|
||||||
"""
|
"""
|
||||||
code = msg.get_int()
|
code = msg.get_int()
|
||||||
text = msg.get_string()
|
text = msg.get_string()
|
||||||
if code == FX_OK:
|
if code == SFTP_OK:
|
||||||
return
|
return
|
||||||
elif code == FX_EOF:
|
elif code == SFTP_EOF:
|
||||||
raise EOFError(text)
|
raise EOFError(text)
|
||||||
else:
|
else:
|
||||||
raise IOError(text)
|
raise IOError(text)
|
||||||
|
|
Loading…
Reference in New Issue