コード例 #1
0
def endpoint_color():
    if not request.remote_addr in studentList:
        # This will have to send along the current address as "forward" eventually
        return redirect('/login')
    '''
    if settingsBoolDict['locked'] == True:
        if not request.remote_addr in whiteList:
            return render_template("message.html", message = "You are not whitelisted. " )
    '''
    if studentList[request.remote_addr]['perms'] > settingsPerms['bar']:
        return render_template(
            "message.html",
            message=
            "You do not have high enough permissions to do this right now. ")
    else:
        try:
            r = int(request.args.get('r'))
            g = int(request.args.get('g'))
            b = int(request.args.get('b'))
        except:
            r = ''
            g = ''
            b = ''
        hex = request.args.get('hex')
        if hex2dec(hex):
            fillBar(hex2dec(hex))
        elif r and b and g:
            fillBar((r, g, b))
        else:
            return "Bad ArgumentsTry <b>/color?hex=#FF00FF</b> or <b>/color?r=255&g=0&b=255</b>"
        pixels.show()
        return render_template("message.html", message="Color sent!")
コード例 #2
0
def endpoint_segment():
    if not request.remote_addr in studentList:
        # This will have to send along the current address as "forward" eventually
        return redirect('/login')
    if studentList[request.remote_addr]['perms'] > settingsPerms['bar']:
        return render_template(
            "message.html",
            message=
            "You do not have high enough permissions to do this right now. ")
    else:
        type = request.args.get('type')
        hex = request.args.get('hex')
        hex2 = request.args.get('hex2')
        start = request.args.get('start')
        end = request.args.get('end')
        if not hex:
            return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF</b> (you need at least one color)"
        if not hex2dec(hex):
            return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF</b> (you did not use a proper hexadecimal color)"
        if not start or not end:
            return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF</b> (you need a start and end point)"
        else:
            try:
                start = int(start)
                end = int(end)
            except:
                return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF</b> (start and end must be and integer)"
        if start > BARPIX or end > BARPIX:
            return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF</b> (Your start or end was higher than the number of pixels: " + str(
                BARPIX) + ")"
        pixRange = range(start, end)
        if type == 'fadein':
            for i, pix in enumerate(pixRange):
                pixels[pix] = fadein(pixRange, i, hex2dec(hex))
        elif type == 'fadeout':
            for i, pix in enumerate(pixRange):
                pixels[pix] = fadeout(pixRange, i, hex2dec(hex))
        elif type == 'blend':
            if not hex:
                return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF&hex2=#00FF00</b> (you need at least two colors)"
            if not hex2dec(hex):
                return "Bad ArgumentsTry <b>/segment?start=0&end=10&hex=#FF00FF&hex2=#00FF00</b> (you did not use a proper hexadecimal color)"
            else:
                for i, pix in enumerate(pixRange):
                    pixels[pix] = blend(pixRange, i, hex2dec(hex),
                                        hex2dec(hex2))
        elif type == 'color':
            for i, pix in enumerate(pixRange):
                pixels[pix] = hex2dec(hex)
        else:
            if hex2dec(hex):
                fillBar(hex2dec(hex))
            else:
                return "Bad ArgumentsTry <b>/color?hex=#FF00FF</b> or <b>/color?r=255&g=0&b=255</b>"
        pixels.show()
        return render_template("message.html", message="Color sent!")
コード例 #3
0
ファイル: app.py プロジェクト: jonat2021888/formbar
def endpoint_color():
    if not settingsStrDict['mode'] == 'playtime':
        return "Not in playtime mode<br>" + backButton
    if settingsBoolDict['locked'] == True:
        if not request.remote_addr in whiteList:
            return "Color changing is locked"
    try:
        r = int(request.args.get('r'))
        g = int(request.args.get('g'))
        b = int(request.args.get('b'))
    except:
        pass
    hex = request.args.get('hex')
    if hex2dec(hex):
        fillBar(hex2dec(hex))
    elif r & b & g:
        fillBar((r, g, b))
    else:
        return "Bad Arguments<br><br>Try <b>/color?hex=#FF00FF</b> or <b>/color?r=255&g=0&b=255</b>"
    pixels.show()
    return "Color sent!<br>" + backButton
コード例 #4
0
def endpoint_say():
    if not request.remote_addr in studentList:
        # This will have to send along the current address as "forward" eventually
        return redirect('/login')
    '''
    if settingsBoolDict['locked'] == True:
        if not request.remote_addr in whiteList:
            return render_template("message.html", message = "You are not whitelisted. " )
    '''
    if studentList[request.remote_addr]['perms'] > settingsPerms['bar']:
        return render_template(
            "message.html",
            message=
            "You do not have high enough permissions to do this right now. ")
    else:
        phrase = request.args.get('phrase')
        fgColor = request.args.get('fg')
        bgColor = request.args.get('bg')
        if phrase:
            if hex2dec(fgColor) and hex2dec(bgColor):
                clearString()
                showString(phrase, 0, hex2dec(fgColor), hex2dec(bgColor))
            else:
                clearString()
                showString(phrase)
            pixels.show()
            #engine.say(p)
            #engine.runAndWait()
        else:
            return render_template(
                "message.html",
                message=
                "<b>phrase</b> must contain a string. \'/say?phrase=<b>\'hello\'</b>\'"
            )
        return render_template("message.html",
                               message="Set phrase to: " + str(phrase) + "")
コード例 #5
0
ファイル: app.py プロジェクト: jonat2021888/formbar
def endpoint_say():
    if not settingsStrDict['mode'] == 'playtime':
        return "Not in playtime mode<br>" + backButton

    if settingsBoolDict['locked'] == True:
        if not request.remote_addr in whiteList:
            return "Say settingsStrDict['mode'] is locked"

    phrase = request.args.get('phrase')
    fgColor = request.args.get('fg')
    bgColor = request.args.get('bg')
    if phrase:
        if hex2dec(fgColor) and hex2dec(bgColor):
            clearString()
            showString(phrase, 0, hex2dec(fgColor), hex2dec(bgColor))
        else:
            clearString()
            showString(phrase)
        pixels.show()
        #engine.say(p)
        #engine.runAndWait()
    else:
        return "<b>phrase</b> must contain a string. \'/say?phrase=<b>\'hello\'</b>\'<br>" + backButton
    return "Set phrase to: " + str(phrase) + "<br>" + backButton