mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-11 11:52:07 +08:00
Refactorings/tweaks from Update Feature work that are worthwhile even without it.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Copyright 2011 Fanficdownloader team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from google.appengine.ext.webapp import util
|
||||
from google.appengine.ext import webapp
|
||||
from google.appengine.api import users
|
||||
from google.appengine.api import taskqueue
|
||||
from google.appengine.api import memcache
|
||||
|
||||
from ffstorage import *
|
||||
|
||||
class Tally(webapp.RequestHandler):
|
||||
def get(self):
|
||||
logging.debug("Starting Tally")
|
||||
user = users.get_current_user()
|
||||
logging.debug("Working as user %s" % user)
|
||||
|
||||
fics = DownloadMeta.all()
|
||||
|
||||
cursor = memcache.get('tally_search_cursor')
|
||||
if cursor:
|
||||
fics.with_cursor(cursor)
|
||||
|
||||
self.response.out.write('"user","url","name","title","author","format","failure","completed","date","version"<br/>')
|
||||
num = 0
|
||||
step = 500
|
||||
results = fics.fetch(step)
|
||||
for d in results:
|
||||
self.response.out.write('"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"<br/>' %
|
||||
(d.user,d.url,d.name,d.title,d.author,
|
||||
d.format,d.failure,d.completed,d.date,
|
||||
d.version))
|
||||
num += 1
|
||||
if num < step:
|
||||
memcache.delete('tally_search_cursor')
|
||||
logging.warn('Tally search reached end, starting over next time.')
|
||||
else:
|
||||
memcache.set('tally_search_cursor',fics.cursor())
|
||||
|
||||
logging.info('Tallied %d fics.' % num)
|
||||
self.response.out.write('<br/>Tallied %d fics.<br/>' % num)
|
||||
|
||||
def main():
|
||||
application = webapp.WSGIApplication([('/tally', Tally),
|
||||
],
|
||||
debug=False)
|
||||
util.run_wsgi_app(application)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
main()
|
||||
Reference in New Issue
Block a user