コード例 #1
0
ファイル: main.py プロジェクト: dbro/smspersonfinder
    def get(self):
        try:
            # TODO(amantri): Switch to post
            source = self.request.get('source')
            message = self.request.get('message')
            time = self.request.get('time')
        except (TypeError, ValueError):
            self.response.out.write("<html><body><p>Invalid inputs</p></body></html>")
            return

        # try to upload to person finder, if it fails (i.e. has no #)
        try:
            logging.debug('trying to use formatted parsing method')
            person = parse_formatted_message(time, source, message)
            upload_to_personfinder(person)

            fields = split_message_to_fields(message)
            reply = 'Added to Person Finder.\nName: %s %s' % (fields['person_first_name'],
                                                               fields['person_last_name'])
            # limit to 140
            reply = reply[0:139]
        except:
            logging.debug('falling back on crowdsource parsing method')
            message = self.create_task_for_crowdsource(time, source, message)
            message.put()
            atomic_add_to_counter(counter_name_new, 1)
            reply = "Sent to crowd-source for input. For instant upload to Person Finder, use the format last_name#first_name#status_of_person#description"

        self.response.out.write("%s" % reply)
コード例 #2
0
ファイル: main.py プロジェクト: neelneelpurk/smspersonfinder
    def get(self):
        try:
            # TODO(amantri): Switch to post
            source = self.request.get('source')
            message = self.request.get('message')
            time = self.request.get('time')
        except (TypeError, ValueError):
            self.response.out.write(
                "<html><body><p>Invalid inputs</p></body></html>")
            return

        # try to upload to person finder, if it fails (i.e. has no #)
        try:
            logging.debug('trying to use formatted parsing method')
            person = parse_formatted_message(time, source, message)
            upload_to_personfinder(person)

            fields = split_message_to_fields(message)
            reply = 'Added to Person Finder.\nName: %s %s' % (
                fields['person_first_name'], fields['person_last_name'])
            # limit to 140
            reply = reply[0:139]
        except:
            logging.debug('falling back on crowdsource parsing method')
            message = self.create_task_for_crowdsource(time, source, message)
            message.put()
            atomic_add_to_counter(counter_name_new, 1)
            reply = "Sent to crowd-source for input. For instant upload to Person Finder, use the format last_name#first_name#status_of_person#description"

        self.response.out.write("%s" % reply)
コード例 #3
0
ファイル: main.py プロジェクト: deepalisingla/smspersonfinder
    def get(self):
        try:
            # TODO(amantri): Switch to post
            source = self.request.get('source')
            message = self.request.get('message')
            time = self.request.get('time')
        except (TypeError, ValueError):
            self.response.out.write("<html><body><p>Invalid inputs</p></body></html>")
            return

        # try to upload to person finder, if it fails (i.e. has no #)
        try:
            logging.debug('trying to use formatted parsing method')
            person = parse_formatted_message(time, source, message)
            upload_to_personfinder(person)
        except:
            logging.debug('falling back on crowdsource parsing method')
            message = self.create_task_for_crowdsource(time, source, message)
            message.put()

        self.response.out.write("<html><body><p>%s</p></body></html>" % message)