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)
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)
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) # Load services services = ServiceManager(settings) # Spin until we have internet, check every 10s while True: settings.set('local-ip', helper.getIP())