Esempio n. 1
0
def sms_to_send():
    if request.method == 'GET':
        print >> sys.stderr, "Received GET request to /sms_to_send/"
        try:
            print >> sys.stderr, "within try"
            messageList = []
            for message in Outbox.select():
                if message.sent == False:
                    mlist = [message.number.number, message.body]
                    messageList.append(mlist)
                else:
                    statement = 'message has already been sent'
            if messageList:
                messageDict = create_Message_Dict(messageList) 
                # print messageDict
                # print type(messageDict)
                messageDict = json.dumps(messageDict)
                for message in Outbox.select():
                    update_query = Outbox.update(sent=True)
                    update_query.execute()
                return messageDict
            else:
                statement = 'empty message list'
            return statement
        except:
            print >> sys.stderr, "within except"
            print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
            print >> sys.stderr, str(sys.exc_info()[1])
            statement = 'An exception has Occurred'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
            return statement
    else:
        print 'oops!'
        return 'nice try but that was not a GET'
Esempio n. 2
0
def index(password):
    print >> sys.stderr, "within index"
    try:
        if password == PASSWORD:
            print >> sys.stderr, "within try"
            sellerList = Seller.select()
            smsList = SMS.select()
            numberList = Number.select()
            l = List.select()
            marketList = Market.select()
            lrList = ListRelationship.select()
            outboxList = Outbox.select()
            return render_template("index.html", title = 'TABLES', sellerList = sellerList, smsList = smsList, l = l, marketList = marketList)
            #return 'hello world'
        else:
            print >> sys.stderr, "wrong password"
    except:
        print >> sys.stderr, "within except"
        print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
        print >> sys.stderr, str(sys.exc_info()[1])
        statement = 'An exception has Occured'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
        return statement