Пример #1
0
 def enableEmulation(self):
     logging.info(
         'Running in emulation mode, settings are stored in /tmp/photoframe/'
     )
     if not os.path.exists('/tmp/photoframe'):
         os.mkdir('/tmp/photoframe')
     path().reassignBase('/tmp/photoframe/')
     path().reassignConfigTxt('extras/config.txt')
Пример #2
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)
Пример #3
0
 def changeRoot(self, newRoot):
   if newRoot is None: return
   newpath = os.path.join(newRoot, '/')
   logging.info('Altering basedir to %s', newpath)
   path().reassignBase(newpath)