Uh oh!
There was an error while loading. Please reload this page.
forked from ghoseb/planet.clojure
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanet.py
More file actions
Latest commit
executable file
·97 lines (81 loc) · 2.85 KB
/
Copy pathplanet.py
File metadata and controls
executable file
·97 lines (81 loc) · 2.85 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
"""The Planet aggregator.
A flexible and easy-to-use aggregator for generating websites.
Visit http://www.planetplanet.org/ for more information and to download
the latest version.
Requires Python 2.1, recommends 2.3.
"""
__authors__= [ "Scott James Remnant <scott@netsplit.com>",
"Jeff Waugh <jdub@perkypants.org>" ]
__license__="Python"
importos, sys
if__name__=="__main__":
config_file="config.ini"
offline=0
verbose=0
only_if_new=0
expunge=0
debug_splice=0
no_publish=0
forarginsys.argv[1:]:
ifarg=="-h"orarg=="--help":
print"Usage: planet [options] [CONFIGFILE]"
print
print"Options:"
print" -v, --verbose DEBUG level logging during update"
print" -o, --offline Update the Planet from the cache only"
print" -h, --help Display this help message and exit"
print" -n, --only-if-new Only spider new feeds"
print" -x, --expunge Expunge old entries from cache"
print" --no-publish Do not publish feeds using PubSubHubbub"
print
sys.exit(0)
elifarg=="-v"orarg=="--verbose":
verbose=1
elifarg=="-o"orarg=="--offline":
offline=1
elifarg=="-n"orarg=="--only-if-new":
only_if_new=1
elifarg=="-x"orarg=="--expunge":
expunge=1
elifarg=="-d"orarg=="--debug-splice":
debug_splice=1
elifarg=="--no-publish":
no_publish=1
elifarg.startswith("-"):
print>>sys.stderr, "Unknown option:", arg
sys.exit(1)
else:
config_file=arg
fromplanetimportconfig
config.load(config_file)
ifverbose:
importplanet
planet.getLogger('DEBUG',config.log_format())
ifnotoffline:
fromplanetimportspider
try:
spider.spiderPlanet(only_if_new=only_if_new)
exceptException, e:
printe
fromplanetimportsplice
doc=splice.splice()
ifdebug_splice:
fromplanetimportlogger
logger.info('writing debug.atom')
debug=open('debug.atom','w')
try:
fromlxmlimportetree
fromStringIOimportStringIO
tree=etree.tostring(etree.parse(StringIO(doc.toxml())))
debug.write(etree.tostring(tree, pretty_print=True))
except:
debug.write(doc.toprettyxml(indent=' ', encoding='utf-8'))
debug.close
splice.apply(doc.toxml('utf-8'))
ifconfig.pubsubhubbub_hub() andnotno_publish:
fromplanetimportpublish
publish.publish(config)
ifexpunge:
fromplanetimportexpunge
expunge.expungeCache