Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remote api, temporarily disable tweeting, don't write to datastore (f…

…ull)
  • Loading branch information...
commit 5b645797b13eee8a5a07c3a0423330005d2cea52 1 parent c416c4c
@al3x authored
Showing with 48 additions and 4 deletions.
  1. +2 −1  .gitignore
  2. +7 −0 app.yaml
  3. +4 −0 cron.yml
  4. +32 −0 downerclear.py
  5. +3 −3 main.py
View
3  .gitignore
@@ -1,2 +1,3 @@
*.log
-*.pyc
+*.pyc
+.DS_Store
View
7 app.yaml
@@ -23,5 +23,12 @@ handlers:
- url: /_tweetcheck
script: tweetcheck.py
+- url: /_downerclear
+ script: downerclear.py
+
+- url: /remote_api
+ script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
+ login: admin
+
- url: .*
script: main.py
View
4 cron.yml
@@ -2,3 +2,7 @@ cron:
- description: tweet on new top down domains
url: /_tweetcheck
schedule: every 10 minutes
+
+- description: delete old downer data
+ url: /_downerclear
+ schedule: every 6 hours
View
32 downerclear.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+import base64, cgi, logging, urllib, wsgiref.handlers
+from datetime import *
+from itertools import *
+
+from downer import *
+
+from google.appengine.ext import db
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp import template
+from google.appengine.api import urlfetch
+
+
+class DownerClear(webapp.RequestHandler):
+ def get(self):
+ hour_ago = datetime.now() + timedelta(minutes=-60)
+ cleared = 0
+
+ query = db.GqlQuery("SELECT __key__ FROM Downer WHERE down_at < :1", hour_ago)
+ results = query.fetch(500)
+ results_size = len(results)
+ db.delete(results)
+ cleared += results_size
+
+ return self.response.out.write("cleared %d" % cleared)
+
+
+def main():
+ application = webapp.WSGIApplication([('/_downerclear', DownerClear)],
+ debug=True)
+ wsgiref.handlers.CGIHandler().run(application)
View
6 main.py
@@ -99,8 +99,8 @@ def render_error(self, url, error='unknown'):
return self.response.out.write(template.render(self.template_path('error.html'), for_template))
def render_down(self, url):
- downer = Downer(domain=url.domain)
- db.put(downer)
+ #downer = Downer(domain=url.domain)
+ #db.put(downer)
for_template = {
'title': "It's not just you!",
@@ -148,7 +148,7 @@ def get(self, domain):
def main():
application = webapp.WSGIApplication([('/', FrontPage),
(r'/(.*)', CheckDomain)],
- debug=True)
+ debug=False)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
Please sign in to comment.
Something went wrong with that request. Please try again.