Ejemplo n.º 1
0
def update():
    global reminderlist
    if request.method=='POST':
        num = request.form['From']
        data = request.form['Body']
        requestType = util.processEvent(num,data)
        if requestType == 0:
            util.sendResponse(num)
        if requestType == 1:
            reminderlist = util.getReminderTimes()
            if threading.activeCount() > 1:
                threading.enumerate()[1].cancel()
            remindersHandler(True,0)
    return redirect(url_for('menu'))
Ejemplo n.º 2
0
def helpsettings():
    global reminderlist
    if request.method == "GET":
        if session.has_key("user") and session["user"] != "":
            tmp = util.getCurrentTime(session["user"])
            time = tmp.split(":")
            if "am" in time[1]:
                amorpm = "am"
            else:
                amorpm = "pm"
            hour = time[0]
            minute = time[1][:-2]
            tmpone = util.getStatus(session["user"])
            return render_template(
                "helpsettings.html",
                minutes=minutelist,
                hourselected=int(hour),
                minuteselected=minute,
                ampm=amorpm,
                enabled=tmpone,
            )
    else:
        if request.form.has_key("Back"):
            return redirect(url_for("calendar", year=int(util.thisYear()), month=util.thisMonth()))
        if request.form.has_key("Submit"):
            hour = request.form["hourselector"]
            minute = request.form["minuteselector"]
            amorpm = request.form["ampmselect"]
            reminders = request.form["enabledselect"]
            hour = str(hour)
            if int(hour) < 10:
                hour = "0" + hour
            newtime = hour + ":" + minute + amorpm
            util.setTime(util.getUserNumber(session["user"]), newtime)
            currentEnabled = util.getStatus(session["user"])
            if currentEnabled == True and reminders == "dis":
                util.changeStatus(util.getUserNumber(session["user"]))
            if currentEnabled == False and reminders == "en":
                util.changeStatus(util.getUserNumber(session["user"]))
            reminderlist = util.getReminderTimes()
            if threading.activeCount() > 1:
                threading.enumerate()[1].cancel()
            remindersHandler(True, 0)
            return redirect(url_for("helpsettings"))
Ejemplo n.º 3
0
def helpsettings():
    global reminderlist
    if request.method =='GET':
        if session.has_key('user') and session['user'] != '':
            tmp = util.getCurrentTime(session['user'])
            time = tmp.split(':')
            if 'am' in time[1]:
                amorpm = 'am'
            else:
                amorpm = 'pm'
            hour = time[0]
            minute = time[1][:-2]
            tmpone = util.getStatus(session['user'])
            return render_template('helpsettings.html',minutes=minutelist,hourselected=int(hour),minuteselected=minute,ampm=amorpm,enabled=tmpone)
    else:
        if request.form.has_key('Back'):
            return redirect(url_for('calendar',year=int(util.thisYear()),month=util.thisMonth()))
        if request.form.has_key('Submit'):
            hour = request.form['hourselector']
            minute = request.form['minuteselector']
            amorpm = request.form['ampmselect']
            reminders = request.form['enabledselect']
            hour = str(hour)
            if int(hour) < 10:
                hour = "0" + hour
            newtime = hour+":"+minute+amorpm
            util.setTime(util.getUserNumber(session['user']),newtime)
            currentEnabled = util.getStatus(session['user'])
            if currentEnabled == True and reminders == 'dis':
                util.changeStatus(util.getUserNumber(session['user']))
            if currentEnabled == False and reminders == 'en':
                util.changeStatus(util.getUserNumber(session['user']))
            reminderlist = util.getReminderTimes()
            if threading.activeCount() > 1:
                threading.enumerate()[1].cancel()
            remindersHandler(True,0)
            return redirect(url_for('helpsettings'))
Ejemplo n.º 4
0
    found = False
    timeinsecsnextperm = 86000
    timeinsecsleast = 86000
    timeinsecsnow = hournow*3600 + minutenow*60 + secnow
    for item in times:
        itemhour = int(item.split(":")[0])
        itemminute = int(item.split(":")[1])
        timeinsecsnext = itemminute*60 + itemhour*3600
        if timeinsecsnext < timeinsecsleast:
            timeinsecsleast = timeinsecsnext
        if timeinsecsnow < timeinsecsnext:
            if timeinsecsnextperm > timeinsecsnext:
                found = True
                timeinsecsnextperm = timeinsecsnext
    if not found:
        timeinsecsnextperm = timeinsecsleast
    nextTime = timeinsecsnextperm - timeinsecsnow
    if nextTime < 0:
        nextTime = (timeinsecsnextperm+86400) - timeinsecsnow
    arguments = (False,nextTime)
    reminder = threading.Timer(nextTime,remindersHandler,args=arguments)
    reminder.setDaemon(True)
    reminder.start()

if __name__ == "__main__":
    reminderlist = util.getReminderTimes()
    remindersHandler(True,0)
    app.debug = True 
    app.run(host='0.0.0.0', port=6004,use_reloader=False)