Пример #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)
Пример #2
0
        logging.error(
            'You must have functional internet connection to use this app')
        display.message('No internet\n\nCheck wifi-config.txt or cable')
        time.sleep(10)
    else:
        break

# Let the display know the URL to use
display.setConfigPage('http://%s:%d/' % (settings.get('local-ip'), 7777))

# Prep random
random.seed(long(time.clock()))
colormatch = colormatch(settings.get('colortemp-script'),
                        2700)  # 2700K = Soft white, lowest we'll go
slideshow = slideshow(display, settings, colormatch)
timekeeper = timekeeper(display.enable, slideshow.start)
slideshow.setQueryPower(timekeeper.getDisplayOn)
slideshow.setServiceManager(services)

timekeeper.setConfiguration(settings.getUser('display-on'),
                            settings.getUser('display-off'))
timekeeper.setAmbientSensitivity(settings.getUser('autooff-lux'),
                                 settings.getUser('autooff-time'))
timekeeper.setPowermode(settings.getUser('powersave'))
colormatch.setUpdateListener(timekeeper.sensorListener)

powermanagement = shutdown(settings.getUser('shutdown-pin'))

if __name__ == "__main__":
    # This allows us to use a plain HTTP callback
    os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'