Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 98 lines (81 sloc) 2.935 kb
70180ab Add a planet shell
Sam Ruby authored
1 #!/usr/bin/env python
2 """The Planet aggregator.
3
4 A flexible and easy-to-use aggregator for generating websites.
5
6 Visit http://www.planetplanet.org/ for more information and to download
7 the latest version.
8
9 Requires Python 2.1, recommends 2.3.
10 """
11
12 __authors__ = [ "Scott James Remnant <scott@netsplit.com>",
13 "Jeff Waugh <jdub@perkypants.org>" ]
14 __license__ = "Python"
15
16
17 import os, sys
18
19 if __name__ == "__main__":
6481eaf @rubys Allow multiple ini files to be specified on the command line
authored
20 config_file = []
70180ab Add a planet shell
Sam Ruby authored
21 offline = 0
22 verbose = 0
7310e14 @rubys Add an "only-if-new" option to planet
authored
23 only_if_new = 0
a51d09e @mortenf Added expunge and preliminary test cases
mortenf authored
24 expunge = 0
ea7c9f2 @rubys Add a debug-splice option
authored
25 debug_splice = 0
fdb9141 @mdomsch add PubSubHubbub-Publisher 1.0 to planet/vendor/, use it to publish at t...
mdomsch authored
26 no_publish = 0
70180ab Add a planet shell
Sam Ruby authored
27
28 for arg in sys.argv[1:]:
29 if arg == "-h" or arg == "--help":
30 print "Usage: planet [options] [CONFIGFILE]"
31 print
32 print "Options:"
33 print " -v, --verbose DEBUG level logging during update"
34 print " -o, --offline Update the Planet from the cache only"
35 print " -h, --help Display this help message and exit"
7310e14 @rubys Add an "only-if-new" option to planet
authored
36 print " -n, --only-if-new Only spider new feeds"
a51d09e @mortenf Added expunge and preliminary test cases
mortenf authored
37 print " -x, --expunge Expunge old entries from cache"
fdb9141 @mdomsch add PubSubHubbub-Publisher 1.0 to planet/vendor/, use it to publish at t...
mdomsch authored
38 print " --no-publish Do not publish feeds using PubSubHubbub"
70180ab Add a planet shell
Sam Ruby authored
39 print
40 sys.exit(0)
41 elif arg == "-v" or arg == "--verbose":
42 verbose = 1
43 elif arg == "-o" or arg == "--offline":
44 offline = 1
7310e14 @rubys Add an "only-if-new" option to planet
authored
45 elif arg == "-n" or arg == "--only-if-new":
46 only_if_new = 1
a51d09e @mortenf Added expunge and preliminary test cases
mortenf authored
47 elif arg == "-x" or arg == "--expunge":
48 expunge = 1
ea7c9f2 @rubys Add a debug-splice option
authored
49 elif arg == "-d" or arg == "--debug-splice":
50 debug_splice = 1
fdb9141 @mdomsch add PubSubHubbub-Publisher 1.0 to planet/vendor/, use it to publish at t...
mdomsch authored
51 elif arg == "--no-publish":
52 no_publish = 1
70180ab Add a planet shell
Sam Ruby authored
53 elif arg.startswith("-"):
54 print >>sys.stderr, "Unknown option:", arg
55 sys.exit(1)
56 else:
6481eaf @rubys Allow multiple ini files to be specified on the command line
authored
57 config_file.append(arg)
70180ab Add a planet shell
Sam Ruby authored
58
c610c93 Load configuration only once
Sam Ruby authored
59 from planet import config
6481eaf @rubys Allow multiple ini files to be specified on the command line
authored
60 config.load(config_file or 'config.ini')
c610c93 Load configuration only once
Sam Ruby authored
61
70180ab Add a planet shell
Sam Ruby authored
62 if verbose:
63 import planet
4010d2d @rubys config: log_format
authored
64 planet.getLogger('DEBUG',config.log_format())
70180ab Add a planet shell
Sam Ruby authored
65
66 if not offline:
67 from planet import spider
58bb4b6 @jcgregorio Seems to working now
jcgregorio authored
68 try:
69 spider.spiderPlanet(only_if_new=only_if_new)
70 except Exception, e:
71 print e
70180ab Add a planet shell
Sam Ruby authored
72
73 from planet import splice
c610c93 Load configuration only once
Sam Ruby authored
74 doc = splice.splice()
ea7c9f2 @rubys Add a debug-splice option
authored
75
76 if debug_splice:
77 from planet import logger
78 logger.info('writing debug.atom')
79 debug=open('debug.atom','w')
80 try:
81 from lxml import etree
82 from StringIO import StringIO
83 tree = etree.tostring(etree.parse(StringIO(doc.toxml())))
84 debug.write(etree.tostring(tree, pretty_print=True))
85 except:
86 debug.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
87 debug.close
88
70180ab Add a planet shell
Sam Ruby authored
89 splice.apply(doc.toxml('utf-8'))
a51d09e @mortenf Added expunge and preliminary test cases
mortenf authored
90
369c6c0 @rubys Fix typo
authored
91 if config.pubsubhubbub_hub() and not no_publish:
fdb9141 @mdomsch add PubSubHubbub-Publisher 1.0 to planet/vendor/, use it to publish at t...
mdomsch authored
92 from planet import publish
93 publish.publish(config)
94
a51d09e @mortenf Added expunge and preliminary test cases
mortenf authored
95 if expunge:
96 from planet import expunge
97 expunge.expungeCache
Something went wrong with that request. Please try again.