def updatePapers(request): """ View for an admin URL that manually runs the script to check the latest arXiv papers. It might be nice to have a meaningful template that shows status information using Ajax. (OnLoad it could send an Ajax request that starts the script, with a callback function that updates a status feed. For partial statuses, the first callback function could start another Ajax query, or maybe there is a better way.) Also there should be graceful behavior and alerts for errors that occur. """ if not request.user.is_staff: # or is_superuser raise Http404() from arxiv.daily import getLatestArxivPapers, getLastWeeksPapers, dbSavePapersAndAuthors # this is some dummy code for testing numNewRSSPapers, numNewRSSAuthors = 1, 2 numNewWeeklyPapers, numNewWeeklyAuthors = 10, 11 # download the RSS feed, parse it, sleep, download the paper information, add them to the db numNewRSSPapers, numNewRSSAuthors = getLatestArxivPapers() numNewWeeklyPapers, numNewWeeklyAuthors = getLastWeeksPapers() # next download all papers for the last week return render_to_response('update_papers.html', locals()) # locals() passes a dictionary of all local variables
#!/usr/bin/env python # On Heroku, schedule a job "python quantphr/dailyupdate.py" or run it from the shell with "heroku run python quantphr/dailyupdate.py" print "Running daily update..." from django.core.management import setup_environ import settings setup_environ(settings) import arxiv from arxiv.daily import getLatestArxivPapers, getLastWeeksPapers, dbSavePapersAndAuthors # this is some dummy code for testing numNewRSSPapers, numNewRSSAuthors = 1, 2 numNewWeeklyPapers, numNewWeeklyAuthors = 10, 11 # download the RSS feed, parse it, sleep, download the paper information, add them to the db numNewRSSPapers, numNewRSSAuthors = getLatestArxivPapers() numNewWeeklyPapers, numNewWeeklyAuthors = getLastWeeksPapers() # next download all papers for the last week