diff options
author | Guido van Rossum <guido@python.org> | 1993-05-24 14:16:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-05-24 14:16:22 (GMT) |
commit | d316607732aa70361d5793f6b301b70fab7ca367 (patch) | |
tree | d87376c3075042ebffdbf8bb13416f8055a5fd13 /Lib/ftplib.py | |
parent | b3f7258f14cb2f3e52236a4087ed82541a173e7b (diff) | |
download | cpython-d316607732aa70361d5793f6b301b70fab7ca367.zip cpython-d316607732aa70361d5793f6b301b70fab7ca367.tar.gz cpython-d316607732aa70361d5793f6b301b70fab7ca367.tar.bz2 |
* ftplib.py: added abort() command (sends oob data).
* Several modules: change "class C(): ..." to "class C: ...".
* flp.py: support for frozen forms.
* Added string.find() which is like index but returns -1 if not found
Diffstat (limited to 'Lib/ftplib.py')
-rw-r--r-- | Lib/ftplib.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py index 1b4705e..cc96a34 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -32,6 +32,10 @@ import socket import string +# Magic number from <socket.h> +MSG_OOB = 0x1 # Process data out of band + + # The standard FTP server control port FTP_PORT = 21 @@ -53,6 +57,10 @@ all_errors = (error_reply, error_temp, error_perm, error_proto, \ CRLF = '\r\n' +# Telnet special characters +DM = chr(242) # Data Mark +IP = chr(244) # Interrupt Process + # Next port to be used by makeport(), with PORT_OFFSET added # (This is now only used when the python interpreter doesn't support # the getsockname() method yet) @@ -152,6 +160,18 @@ class FTP: if resp[0] <> '2': raise error_reply, resp + # Abort a file transfer. Uses out-of-band data. + # This does not follow the procedure from the RFC to send Telnet + # IP and Synch; that doesn't seem to work with the servers I've + # tried. Instead, just send the ABOR command as OOB data. + def abort(self): + line = 'ABOR' + CRLF + if self.debugging > 1: print '*put urgent*', `line` + self.sock.send(line, MSG_OOB) + resp = self.getmultiline() + if resp[:3] not in ('426', '226'): + raise error_proto, resp + # Send a command and return the response def sendcmd(self, cmd): self.putcmd(cmd) |