예제 #1
0
def createdb():
	print 'creating db..'
	db.drop_all()
	db.create_all()
	Role.insert_roles()

	print 'adding feed sources..'
	with open('sources.yaml', 'r') as f:
		feed_sources = yaml.load(f)

	# Insert feedprovider
	for site in feed_sources:
		provider_name = unicode(site['name'])
		provider_domain = site['domain']
		provider = FeedProvider(name = provider_name,
								domain = provider_domain,
								favicon = site['favicon'])
		db.session.add(provider)
		db.session.commit()

		# Add feedsource
		for channel_name in site['channels']:
			source_name = unicode(site['name'] + ' - ' + channel_name)
			source_href = site['channels'][channel_name]
			fs = FeedSource(name=source_name, url=source_href, provider=provider)
			db.session.add(fs)

	db.session.commit()

	print 'add feed articles..'
	from app.mod_crawler.fetch import update_db
	update_db()
예제 #2
0
def updatedb():
	from app.mod_crawler.fetch import update_db
	update_db()