File: nglister

package info (click to toggle)
nglister 1.0.2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 140 kB
  • ctags: 12
  • sloc: makefile: 79; python: 30
file content (54 lines) | stat: -rwxr-xr-x 1,872 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- Mode: Python; -*-
# Copyright (C) 2002, 2003 John Goerzen
# <jgoerzen@complete.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

rev = '$Rev: 5 $'
version = '1.0.0'

import sys, nntplib
from optparse import OptionParser

usage = """
   USAGE: nglister [-u username] [-p password] [-P port] hostname file
   """

parser = OptionParser(usage = usage)
parser.add_option('-u', action="store", type="string", dest="username",
                  help="Specify a username for logging into NNTP server")
parser.add_option('-p', action="store", type="string", dest="password",
                  help="Specify a password for logging into NNTP server")
parser.add_option('-P', action="store", type="int", dest="port",
                  help="Specify a port for NNTP server", default=119)

(options, args) = parser.parse_args()

try:
    hostname = args[0]
    filename = args[1]
except IndexError:
    parser.print_help()
    sys.exit(255)

# OK, ready to go.

s = nntplib.NNTP(hostname, options.port, options.username, options.password,
                 1)
(response, results) = s.longcmd("LIST " + filename)
results.sort()
print response
print "\n".join(results)