blob: cc3068e00640d535e8a1a27c33d5767fe26ad2b9 (
plain)
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
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# fetch.py
#
# You can use this script with cron, for example:
# */30 * * * * cd ~/.pyaggr3g470r/ ; python fetch.py
# to fetch articles every 30 minutes.
import sys
if 'threading' in sys.modules:
raise Exception('threading module loaded before patching!')
import gevent.monkey
gevent.monkey.patch_thread()
from pyaggr3g470r import crawler
from pyaggr3g470r.models import User
if __name__ == "__main__":
# Point of entry in execution mode
try:
feed_id = int(sys.argv[2])
except:
feed_id = None
users = []
try:
users = User.query.filter(User.email == sys.argv[1]).all()
except:
users = User.query.all()
for user in users:
print "Fetching articles for", user.nickname
feed_getter = crawler.FeedGetter(user.email)
feed_getter.retrieve_feed(feed_id)
|