| | |
- exceptions.Exception
-
- NNTPError
-
- NNTPDataError
- NNTPDataError
- NNTPPermanentError
- NNTPPermanentError
- NNTPProtocolError
- NNTPProtocolError
- NNTPReplyError
- NNTPReplyError
- NNTPTemporaryError
- NNTPTemporaryError
- NNTP
class NNTP |
| |
# The class itself |
| |
- __init__(self, host, port=119, user=None, password=None, readermode=None)
- Initialize an instance. Arguments:
- host: hostname to connect to
- port: port to connect to (default the standard NNTP port)
- user: username to authenticate with
- password: password to use with username
- readermode: if true, send 'mode reader' command after
connecting.
readermode is sometimes necessary if you are connecting to an
NNTP server on the local machine and intend to call
reader-specific comamnds, such as `group'. If you get
unexpected NNTPPermanentErrors, you might need to set
readermode.
- artcmd(self, line)
- Internal: process a HEAD, BODY or ARTICLE command.
- article(self, id)
- Process an ARTICLE command. Argument:
- id: article number or message id
Returns:
- resp: server response if succesful
- nr: article number
- id: message id
- list: the lines of the article
- body(self, id)
- Process a BODY command. Argument:
- id: article number or message id
Returns:
- resp: server response if succesful
- nr: article number
- id: message id
- list: the lines of the article's body
- date(self)
- Process the DATE command. Arguments:
None
Returns:
resp: server response if succesful
date: Date suitable for newnews/newgroups commands etc.
time: Time suitable for newnews/newgroups commands etc.
- debug = set_debuglevel(self, level)
- getline(self)
- Internal: return one line from the server, stripping CRLF.
Raise EOFError if the connection is closed.
- getlongresp(self)
- Internal: get a response plus following text from the server.
Raise various errors if the response indicates an error.
- getresp(self)
- Internal: get a response from the server.
Raise various errors if the response indicates an error.
- getwelcome(self)
- Get the welcome message from the server
(this is read and squirreled away by __init__()).
If the response code is 200, posting is allowed;
if it 201, posting is not allowed.
- group(self, name)
- Process a GROUP command. Argument:
- group: the group name
Returns:
- resp: server response if succesful
- count: number of articles (string)
- first: first article number (string)
- last: last article number (string)
- name: the group name
- head(self, id)
- Process a HEAD command. Argument:
- id: article number or message id
Returns:
- resp: server response if succesful
- nr: article number
- id: message id
- list: the lines of the article's header
- help(self)
- Process a HELP command. Returns:
- resp: server response if succesful
- list: list of strings
- ihave(self, id, f)
- Process an IHAVE command. Arguments:
- id: message-id of the article
- f: file containing the article
Returns:
- resp: server response if succesful
Note that if the server refuses the article an exception is raised.
- last(self)
- Process a LAST command. No arguments. Return as for STAT.
- list(self)
- Process a LIST command. Return:
- resp: server response if succesful
- list: list of (group, last, first, flag) (strings)
- longcmd(self, line)
- Internal: send a command and get the response plus following text.
- newgroups(self, date, time)
- Process a NEWGROUPS command. Arguments:
- date: string 'yymmdd' indicating the date
- time: string 'hhmmss' indicating the time
Return:
- resp: server response if succesful
- list: list of newsgroup names
- newnews(self, group, date, time)
- Process a NEWNEWS command. Arguments:
- group: group name or '*'
- date: string 'yymmdd' indicating the date
- time: string 'hhmmss' indicating the time
Return:
- resp: server response if succesful
- list: list of article ids
- next(self)
- Process a NEXT command. No arguments. Return as for STAT.
- post(self, f)
- Process a POST command. Arguments:
- f: file containing the article
Returns:
- resp: server response if succesful
- putcmd(self, line)
- Internal: send one command to the server (through putline()).
- putline(self, line)
- Internal: send one line to the server, appending CRLF.
- quit(self)
- Process a QUIT command and close the socket. Returns:
- resp: server response if succesful
- set_debuglevel(self, level)
- Set the debugging level. Argument 'level' means:
0: no debugging output (default)
1: print commands and responses but not body text etc.
2: also print raw lines read and sent before stripping CR/LF
- shortcmd(self, line)
- Internal: send a command and get the response.
- slave(self)
- Process a SLAVE command. Returns:
- resp: server response if succesful
- stat(self, id)
- Process a STAT command. Argument:
- id: article number or message id
Returns:
- resp: server response if succesful
- nr: the article number
- id: the article id
- statcmd(self, line)
- Internal: process a STAT, NEXT or LAST command.
- statparse(self, resp)
- Internal: parse the response of a STAT, NEXT or LAST command.
- xgtitle(self, group)
- Process an XGTITLE command (optional server extension) Arguments:
- group: group name wildcard (i.e. news.*)
Returns:
- resp: server response if succesful
- list: list of (name,title) strings
- xhdr(self, hdr, str)
- Process an XHDR command (optional server extension). Arguments:
- hdr: the header type (e.g. 'subject')
- str: an article nr, a message id, or a range nr1-nr2
Returns:
- resp: server response if succesful
- list: list of (nr, value) strings
- xover(self, start, end)
- Process an XOVER command (optional server extension) Arguments:
- start: start of range
- end: end of range
Returns:
- resp: server response if succesful
- list: list of (art-nr, subject, poster, date,
id, references, size, lines)
- xpath(self, id)
- Process an XPATH command (optional server extension) Arguments:
- id: Message id of article
Returns:
resp: server response if succesful
path: directory path to article
|
|