diff options
author | Guido van Rossum <guido@python.org> | 1997-10-20 23:29:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-20 23:29:44 (GMT) |
commit | dd65975ac716a9a3beaa80189ab72ce0f88779e4 (patch) | |
tree | 564825488f17ef1beb9faa08097a41b167add9f6 /Lib/nntplib.py | |
parent | 4a2a621907679f74d2c8f255902f0565e997f333 (diff) | |
download | cpython-dd65975ac716a9a3beaa80189ab72ce0f88779e4.zip cpython-dd65975ac716a9a3beaa80189ab72ce0f88779e4.tar.gz cpython-dd65975ac716a9a3beaa80189ab72ce0f88779e4.tar.bz2 |
Patch by Charles G. Waldman to add optional user and password
arguments to NNTP.__init__(), for nntp servers that need them.
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r-- | Lib/nntplib.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py index a5e0234..a266cbd 100644 --- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -63,7 +63,7 @@ class NNTP: # - host: hostname to connect to # - port: port to connect to (default the standard NNTP port) - def __init__(self, host, port = NNTP_PORT): + def __init__(self, host, port = NNTP_PORT, user=None, password=None): self.host = host self.port = port self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -71,6 +71,15 @@ class NNTP: self.file = self.sock.makefile('rb') self.debugging = 0 self.welcome = self.getresp() + if user: + resp = self.shortcmd('authinfo user '+user) + if resp[:3] == '381': + if not password: + raise error_reply, resp + else: + resp = self.shortcmd('authinfo pass '+password) + if resp[:3] != '281': + raise error_perm, resp # Get the welcome message from the server # (this is read and squirreled away by __init__()). |