Exemplo n.º 1
0
 def get(self):
     logging.info('Got refresh request')
     # We try 3 times in a row because if the request is stopped after 10 seconds we wouldn't
     # get any answer. The SIPwPing server will save the value in the cache anyway, so the second (or third)
     # time we try we'll get an answer immediately
     for x in xrange(0, 3):
         try:
             result = urlfetch.fetch(url='http://*****:*****@sip.voice.google.com'}),
                                 headers={'Content-Type':'application/json'},
                                 allow_truncated=False,
                                 deadline=10)
             try:
                 d = simplejson.loads(result.content)
             except Exception, e:
                 logging.warning('Error decoding response: %s' % e)
             else:
                 logging.info('Data: %r' % d)
                 obj = ServerState.get_or_insert('server_state')
                 obj.code = int(d.get('code'))
                 obj.reason = d.get('reason')
                 obj.timestamp = d.get('timestamp')
                 obj.put()
                 break
Exemplo n.º 2
0
 def get(self):
     try:
         obj = ServerState.get_by_key_name('server_state')
     except db.BadKeyError:
         obj = None
     data = {'server_state': obj}
     path = os.path.join(os.path.dirname(__file__), 'index.html')
     self.response.out.write(template.render(path, data))
Exemplo n.º 3
0
 def get(self):
     try:
         obj = ServerState.get_by_key_name('server_state')
     except db.BadKeyError:
         obj = None
     data = {'server_state': obj}
     path = os.path.join(os.path.dirname(__file__), 'index.html')
     self.response.out.write(template.render(path, data))