예제 #1
0
def cfg_keyvalue(key, value):
    # Depending on PUT/GET we will either change or read
    # values. If key is unknown, then this call fails with 404
    if key is not None:
        if settings.getUser(key) is None:
            abort(404)
            return

    if request.method == 'PUT':
        if key == "keywords":
            # Keywords has its own API
            abort(404)
            return
        settings.setUser(key, value)
        settings.save()
        if key in ['width', 'height', 'depth', 'tvservice']:
            display.setConfiguration(settings.getUser('width'),
                                     settings.getUser('height'),
                                     settings.getUser('depth'),
                                     settings.getUser('tvservice'))
            display.enable(True, True)
        if key in ['display-on', 'display-off']:
            timekeeper.setConfiguration(settings.getUser('display-on'),
                                        settings.getUser('display-off'))
        return jsonify({'status': True})

    elif request.method == 'GET':
        if key is None:
            return jsonify(settings.getUser())
        else:
            return jsonify({key: settings.getUser(key)})
    abort(404)
예제 #2
0
def cfg_keyvalue(key, value):
    global powermanagement

    # Depending on PUT/GET we will either change or read
    # values. If key is unknown, then this call fails with 404
    if key is not None:
        if settings.getUser(key) is None:
            abort(404)
            return

    if request.method == 'PUT':
        status = True
        if key == "keywords":
            # Keywords has its own API
            abort(404)
            return
        settings.setUser(key, value)
        if key in ['display-driver']:
            drv = settings.getUser('display-driver')
            if drv == 'none':
                drv = None
            special = drivers.activate(drv)
            if special is None:
                settings.setUser('display-driver', 'none')
                settings.setUser('display-special', None)
                status = False
            else:
                settings.setUser('display-special', special)
        if key in ['timezone']:
            # Make sure we convert + to /
            settings.setUser('timezone', value.replace('+', '/'))
            helper.timezoneSet(settings.getUser('timezone'))
        if key in ['resolution', 'tvservice']:
            width, height, tvservice = display.setConfiguration(
                value, settings.getUser('display-special'))
            settings.setUser('tvservice', tvservice)
            settings.setUser('width', width)
            settings.setUser('height', height)
            display.enable(True, True)
        if key in ['display-on', 'display-off']:
            timekeeper.setConfiguration(settings.getUser('display-on'),
                                        settings.getUser('display-off'))
        if key in ['autooff-lux', 'autooff-time']:
            timekeeper.setAmbientSensitivity(settings.getUser('autooff-lux'),
                                             settings.getUser('autooff-time'))
        if key in ['powersave']:
            timekeeper.setPowermode(settings.getUser('powersave'))
        if key in ['shutdown-pin']:
            powermanagement.stopmonitor()
            powermanagement = shutdown(settings.getUser('shutdown-pin'))
        settings.save()
        return jsonify({'status': status})

    elif request.method == 'GET':
        if key is None:
            return jsonify(settings.getUser())
        else:
            return jsonify({key: settings.getUser(key)})
    abort(404)
예제 #3
0
def cfg_keywords():
    if request.method == 'GET':
        return jsonify({'keywords': settings.getUser('keywords')})
    elif request.method == 'POST' and request.json is not None:
        result = True
        if 'id' not in request.json:
            if settings.addKeyword(request.json['keywords']):
                settings.save()
        else:
            if settings.removeKeyword(request.json['id']):
                settings.save()
            else:
                result = False
        return jsonify({'status': result})
    abort(500)
예제 #4
0
m = re.search('([0-9]+)x([0-9]+)', cmdline.size)
if m is None:
    logging.error('--size has to be WIDTHxHEIGHT')
    sys.exit(1)

display = display(cmdline.emulate, int(m.group(1)), int(m.group(2)))

if not settings.load():
    # First run, grab display settings from current mode
    current = display.current()
    if current is not None:
        logging.info('No display settings, using: %s' % repr(current))
        settings.setUser('tvservice',
                         '%s %s HDMI' % (current['mode'], current['code']))
        settings.save()
    else:
        logging.info('No display attached?')
if settings.getUser('timezone') == '':
    settings.setUser('timezone', helper.timezoneCurrent())
    settings.save()

width, height, tvservice = display.setConfiguration(
    settings.getUser('tvservice'), settings.getUser('display-special'))
settings.setUser('tvservice', tvservice)
settings.setUser('width', width)
settings.setUser('height', height)
settings.save()

# Force display to desired user setting
display.enable(True, True)
예제 #5
0
def oauthSetToken(token):
  settings.set('oauth_token', token)
  settings.save()