Example #1
0
    def __init__(self, cmdline):
        self.void = open(os.devnull, 'wb')
        random.seed(long(time.clock()))

        self.emulator = cmdline.emulate
        if self.emulator:
            self.enableEmulation()
        if cmdline.basedir is not None:
            self.changeRoot(cmdline.basedir)
        if not path().validate():
            sys.exit(255)

        self.cacheMgr = CacheManager()
        self.settingsMgr = settings()
        self.driverMgr = drivers()
        self.displayMgr = display(self.emulator)
        self.serviceMgr = ServiceManager(self.settingsMgr, self.cacheMgr)

        self.colormatch = colormatch(
            self.settingsMgr.get('colortemp-script'),
            2700)  # 2700K = Soft white, lowest we'll go
        self.slideshow = slideshow(self.displayMgr, self.settingsMgr,
                                   self.colormatch)
        self.timekeeperMgr = timekeeper(self.displayMgr.enable,
                                        self.slideshow.start)
        self.powerMgr = shutdown(self.settingsMgr.getUser('shutdown-pin'))

        # Validate all settings, prepopulate with defaults if needed
        self.validateSettings()

        self.cacheMgr.validate()
        self.cacheMgr.enableCache(
            self.settingsMgr.getUser('enable-cache') == 1)

        # Tie all the services together as needed
        self.timekeeperMgr.setConfiguration(
            self.settingsMgr.getUser('display-on'),
            self.settingsMgr.getUser('display-off'))
        self.timekeeperMgr.setAmbientSensitivity(
            self.settingsMgr.getUser('autooff-lux'),
            self.settingsMgr.getUser('autooff-time'))
        self.timekeeperMgr.setPowermode(self.settingsMgr.getUser('powersave'))
        self.colormatch.setUpdateListener(self.timekeeperMgr.sensorListener)

        self.slideshow.setQueryPower(self.timekeeperMgr.getDisplayOn)
        self.slideshow.setServiceManager(self.serviceMgr)
        self.slideshow.setCacheManager(self.cacheMgr)
        self.slideshow.setCountdown(cmdline.countdown)

        # Prep the webserver
        self.setupWebserver(cmdline.listen, cmdline.port)

        # Force display to desired user setting
        self.displayMgr.enable(True, True)
Example #2
0
@app.route('/control/<cmd>')
@auth.login_required
def control_slideshow(cmd):
    slideshow.createEvent(cmd)
    return jsonify({'control': True})


settings = settings()
drivers = drivers()

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()
Example #3
0
                return jsonify({'status': 'Done'})
    if request.url.endswith('/config/fields'):
        return jsonify(services.getServiceConfigurationFields(id))
    if request.url.endswith('/config'):
        if request.method == 'POST' and j is not None and 'config' in j:
            if services.setServiceConfiguration(id, j['config']):
                return 'Configuration saved', 200
        elif request.method == 'GET':
            return jsonify(services.getServiceConfiguration(id))

    abort(500)


settings = settings()
drivers = drivers()
display = display(cmdline.emulatefb)

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()
Example #4
0
    return app.send_static_file('template/' + file)


settings = settings()
if not settings.load():
    # First run, grab display settings from current mode
    current = display.current()
    logging.info('No display settings, using: %s' % repr(current))
    settings.setUser(
        'tvservice',
        '%s %s %s' % (current['group'], current['mode'], current['drive']))
    settings.setUser('width', int(current['width']))
    settings.setUser('height', int(current['height']))
    settings.save()

display = display(settings.getUser('width'), settings.getUser('height'),
                  settings.getUser('depth'), settings.getUser('tvservice'))

# Force display to desired user setting
display.enable(True, True)

# Spin until we have internet, check every 10s
while True:
    settings.set('local-ip', helper.getIP())

    if settings.get('local-ip') is None:
        logging.error(
            'You must have functional internet connection to use this app')
        display.message('No internet')
        time.sleep(10)
    else:
        break
Example #5
0
@app.route('/<file>')
@auth.login_required
def web_main(file):
  if file is None:
    return app.send_static_file('index.html')
  else:
    return app.send_static_file(file)

@app.route('/template/<file>')
@auth.login_required
def web_template(file):
  return app.send_static_file('template/' + file)

settings = settings()
drivers = drivers()
display = display()

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'))