Initial skeleton.
[0mirror.git] / 0mirror
blobe697e70e7bf0bd94faa82c99b79f67d137ad28c4
1 #!/usr/bin/env python
2 from zeroinstall import SafeException
3 from optparse import OptionParser
4 import os, sys
5 from logging import info, debug
7 version = '0.1'
9 parser = OptionParser(usage="usage: %prog [options] PUBLIC-DIR")
10 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
11 parser.add_option("-V", "--version", help="display version information", action='store_true')
13 (options, args) = parser.parse_args()
15 if options.version:
16 print "0mirror (zero-install) " + version
17 print "Copyright (C) 2007 Thomas Leonard"
18 print "This program comes with ABSOLUTELY NO WARRANTY,"
19 print "to the extent permitted by law."
20 print "You may redistribute copies of this program"
21 print "under the terms of the GNU General Public License."
22 print "For more information about these matters, see the file named COPYING."
23 sys.exit(0)
25 if options.verbose:
26 import logging
27 logger = logging.getLogger()
28 if options.verbose == 1:
29 logger.setLevel(logging.INFO)
30 else:
31 logger.setLevel(logging.DEBUG)
33 if len(args) != 1:
34 parser.print_help()
35 sys.exit(1)
36 public_dir = args[0]
38 FEED_FILE = os.path.join(public_dir, 'feedlist')
40 try:
41 if not os.path.isfile(FEED_FILE):
42 raise SafeException("File '%s' does not exist. It should contain a list of feed URLs, one per line")
43 feeds = file(options.feed_file).read().split('\n')
44 for feed in feeds:
45 print feed
46 except KeyboardInterrupt, ex:
47 print >>sys.stderr, "Aborted at user's request"
48 sys.exit(1)
49 except SafeException, ex:
50 if options.verbose: raise
51 print >>sys.stderr, ex
52 sys.exit(1)