-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprobereceive.py
More file actions
30 lines (27 loc) · 929 Bytes
/
probereceive.py
File metadata and controls
30 lines (27 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
#
# Copyright 2014 FreeThought Design.
#
# Licensed under the MIT license.
#
import logging, webapp2, mxflow
from datetime import datetime
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext import ndb
from google.appengine.api import mail
from models import *
class LogSenderHandler(InboundMailHandler):
def receive(self, mail_message):
logging.info("Got me a message from: " + mail_message.sender)
try:
probe_key = ndb.Key(urlsafe=mail_message.subject)
except:
logging.info('bad key')
else:
# TODO: Don't accept replies for timed-out probes.
logging.info(probe_key)
probe = probe_key.get()
probe.time_rec = datetime.now()
probe.status = 1
probe.put()
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)