Commits

Frederic De Groef committed 4a47c7d

stupid double negatives. also, added some logging for gehol status updates.

Comments (0)

Files changed (4)

 import httplib
 import socket
-
+import logging
 from google.appengine.ext import webapp
 from google.appengine.ext.webapp.util import run_wsgi_app
 from status import set_status_down
     headers = {"Content-type": "application/x-www-form-urlencoded",
                "Accept": "text/plain"}
 
-    conn = httplib.HTTPConnection(host)
     try:
+        conn = httplib.HTTPConnection(host)
         conn.request("GET", '/', headers = headers)
         response = conn.getresponse()
         set_status_down(False)
 
 class UpdateGeholStatus(webapp.RequestHandler):
     def get(self):
+        logging.info("Launching UpdateGeholStatus cron job")
         update_gehol_status()
         
 application = webapp.WSGIApplication([('/geholstatus', UpdateGeholStatus)],
 
 
         template_values = {'requests': requests,
-                           'gehol_status': is_status_down(),
+                           'gehol_is_down': is_status_down(),
                            'last_status_update': get_last_status_update()
                         }
 
             }
 
         template_values.update(cal.metadata)
-        template_values.update({'gehol_status' : is_status_down(),
+        template_values.update({'gehol_is_down' : is_status_down(),
                                 'last_status_update': get_last_status_update()})
 
         path = os.path.join(os.path.dirname(__file__), 'templates/calendar.html')
 
-
+import logging
 from google.appengine.ext import db
 
 class GeholStatus(db.Model):
     last_checked = db.DateTimeProperty(auto_now=True)
 
 def create_unique_entry():
+    logging.info("Creating unique GeholStatus datastore entry")
     unique = GeholStatus(key_name='unique')
     unique.put()
     return unique
 
 
 def get_unique_status_entry():
-    #status_entry = db.GqlQuery("SELECT * FROM GeholStatus WHERE __key__ = 'unique'")
+    logging.info("Getting Gehol status from datastore")
     status_entry = GeholStatus.get_by_key_name('unique')
     if not status_entry:
         status_entry = create_unique_entry()
 
     return status_entry
-    
 
 def is_status_down():
     status_entry = get_unique_status_entry()
 
 def set_status_down(down=True):
     status_entry = get_unique_status_entry()
+    logging.info("Setting Gehol's down status to %s" % down)
     status_entry.is_down = down
     status_entry.put()
           <!--status-->
           <h3>GeHOL Status</h3>
           <div class="box">
-            {% if gehol_status %}
+            {% if gehol_is_down %}
                 <span style="vertical-align:top;">
+	                <img src="/stylesheets/blueprint/plugins/buttons/icons/cross.png" alt=""/>
+                    GeHOL server is offline.
+                </span>
+                Relax and try again later. There is nothing we can do right now.
+                <br/>
+            {% else %}
+              <span style="vertical-align:top;">
                 <img src="/stylesheets/blueprint/plugins/buttons/icons/tick.png" alt=""/>
-                Everything shiny, cap'n!
-                </span>
-            {% else %}
-                <span style="vertical-align:top;">
-	            <img src="/stylesheets/blueprint/plugins/buttons/icons/cross.png" alt=""/>
-                GeHOL server is offline.
-                    </span>
-                <br/>
-                Relax and try again later. There is nothing we can do right now.
+                GeHOL server is online
+              </span>
+              <br/>
+              Everything shiny, cap'n!
             {% endif %}
 
             <br/><br/>