def startClient(self, answer): log("", self) if answer is True: self.controller.killEnigmalight(None, self.controller.switchtoNetwork()) else: self.close()
def writeDynamic(self): log("",self) self.setStatusBarInfo("writeDynamic") data ="set threshold " + str(config.plugins.enigmalight.threshold.getValue()) + "\n" data +="set mode 2\n" self.sockClass.setCommand(data)
def loadConfig(): log("",None,"__init__::loadConfig()") if os.path.isfile(enigmalight_config): config.plugins.enigmalight.loadFromFile(enigmalight_config) config.plugins.enigmalight.load() else: Logfile("no configfile found!")
def keySave(self): log("",self) #check ip if network is true, before save if config.plugins.enigmalight.network_onoff.getValue(): #check ip if not validIP(str(config.plugins.enigmalight.address.getText())): showMessage(self.session,_("Ip address %s is not accepted, check your input and try again.") %(str(config.plugins.enigmalight.address.getText())),"W") else: #check connection if not testDaemonConnectivity(config.plugins.enigmalight.address.getText(),config.plugins.enigmalight.port.value): showMessage(self.session,_("Enigmalight can't connect with %s:%s,\ncheck your input and try again.") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())),"W") else: showMessage(self.session,_("Test Connection with %s:%s, succesfull!") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())),"I") self.saveAll() message = self.session.openWithCallback(self.startClient,MessageBox,_("Do you want to (re)start the client and connect with %s:%s ?") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) else: self.saveAll() if self._hasNetworkChanged: self._hasNetworkChanged = False if self.controller.lightsEnabled: self.controller.killEnigmalight(None,None) message = self.session.openWithCallback(self.startGrabber,MessageBox,_("Do you want to (re)start the client ?"), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) elif self._binTypeChanged: message = self.session.openWithCallback(self.restartEnigmaLight,MessageBox,_("Type of enigmalight has changed, Start this type of Enigmalight ?"), MessageBox.TYPE_YESNO) message.setTitle(_("Start ?")) else: self.close(None)
def readInfo(self): #log("",self) try: self.serverstate = self.sockClass.getServerState() self.current_mode = str(self.sockClass.getMode()) self.current_fps = str(self.sockClass.getFPS()) self.current_resolution = str(self.sockClass.getRes()) if self.current_mode == "0" and self.serverstate: self.connectedAddres = self.sockClass.getConnectedAddress() else: self.connectedAddres = None except: self.current_fps = "0" self.current_resolution = "0x0" self.current_mode = "Off" self.current_cpu = "0" from traceback import format_exc log("",self,"Error: "+format_exc()) try: open(getCrashFilePath(),"w").write(format_exc()) except: pass
def writeServer(self): log("",self) self.setStatusBarInfo("writeServer") data ="set threshold 0\n" data +="set mode 0\n" self.sockClass.setCommand(data)
def Autostart(reason, session=None, **kwargs): try: if reason == 0: Prepare() if config.plugins.enigmalight.autostart.getValue() != str(0): log("",None,"plugin::Autostart(reason, session=None, **kwargs)) > Autostart enigmalight..") if config.plugins.enigmalight.autostart.getValue() == str(1): controller.Control("start", "server") elif config.plugins.enigmalight.autostart.getValue() == str(2): controller.Control("start", "dynamic") elif config.plugins.enigmalight.autostart.getValue() == str(3): controller.Control("start", "moodlamp") if config.plugins.enigmalight.remote_server.getValue(): controller.StartServer() else: controller.StopServer() except: from traceback import format_exc log("",None,"plugin::Autostart()) > Error: " +format_exc()) try: open(getCrashFilePath(),"w").write(format_exc()) except: pass
def sendAll(self,sendValues=False): log("",self) if sendValues == True or self.current_mode != "99" and self.current_mode != "off": #only send values if grabber or moodlamp is running if self.sockClass.ping(): self.setStatusBarInfo("Set all values..") ################################## # Set mode, color etc... ################################## if self.lightsEnabled and self.current_mode != "0": if config.plugins.enigmalight.mode.getValue() == str(1): ############### # Moodlamp ############### self.writeMoodlamp() elif config.plugins.enigmalight.mode.getValue() == str(2): ############### # Dynamic ############### self.writeDynamic()
def killEnigmalightFinisched(self, result, retval, extra_args = None): log("",self) (values, callback) = extra_args log("",self,"values " + str(values)) log("",self,"result " + str(result)) log("",self,"retval " + str(retval)) log("",self,"callback " + str(callback)) time.sleep(1) if len(str(result)) == 0: self.setStatusBarInfo(_("Enigmalight killed.")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session,_("Enigmalight killed.","I")) else: self.setStatusBarInfo(_("Enigmalight not killed!")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session,_("Enigmalight not killed\nresult: %s") %(str(result)),"I") if callback != None: if self.callbackArgs != None: callback(self.callbackArgs) # now do callback from saved callback else: callback()
def saveCustom(self,profilenr): try: log("",self) fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "wb") fo.write(str(config.plugins.enigmalight.saturation.value)+"|") fo.write(str(config.plugins.enigmalight.value.value)+"|") fo.write(str(config.plugins.enigmalight.speed.value)+"|") fo.write(str(config.plugins.enigmalight.valuemax.value)+"|") fo.write(str(config.plugins.enigmalight.valuemin.value)+"|") fo.write(str(config.plugins.enigmalight.saturationmin.value)+"|") fo.write(str(config.plugins.enigmalight.saturationmax.value)+"|") fo.write(str(config.plugins.enigmalight.gamma.value)+"|") fo.write(str(config.plugins.enigmalight.threshold.value)+"|") fo.write(str(config.plugins.enigmalight.autospeed.value)) fo.close(); except: from traceback import format_exc log("Error:" +format_exc(),self) try: open(getCrashFilePath(),"w").write(format_exc()) showMessage(self._session,_("Can't write settings to profile...", "W", timeout = 10)) except: pass
def sendAll(self, sendValues=False): log("", self) if sendValues == True or self.current_mode != "99" and self.current_mode != "off": #only send values if grabber or moodlamp is running if self.sockClass.ping(): self.setStatusBarInfo("Set all values..") ################################## # Set mode, color etc... ################################## if self.lightsEnabled and self.current_mode != "0": if config.plugins.enigmalight.mode.getValue() == str(1): ############### # Moodlamp ############### self.writeMoodlamp() elif config.plugins.enigmalight.mode.getValue() == str(2): ############### # Dynamic ############### self.writeDynamic()
def getCustom(self,profilenr): try: log("",self) fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "r") customsettings = fo.read(256) fo.close() customsettings = customsettings.split("|") config.plugins.enigmalight.saturation.setValue(customsettings[0]) config.plugins.enigmalight.value.setValue(customsettings[1]) config.plugins.enigmalight.speed.setValue(customsettings[2]) config.plugins.enigmalight.valuemax.setValue(customsettings[3]) config.plugins.enigmalight.valuemin.setValue(customsettings[4]) config.plugins.enigmalight.saturationmin.setValue(customsettings[5]) config.plugins.enigmalight.saturationmax.setValue(customsettings[6]) config.plugins.enigmalight.gamma.setValue(customsettings[7]) config.plugins.enigmalight.threshold.setValue(customsettings[8]) config.plugins.enigmalight.autospeed.setValue(customsettings[9]) if self.controller.lightsEnabled: self.controller.writeSettings() except: from traceback import format_exc log("Error: " + format_exc(),self) try: open(getCrashFilePath(),"w").write(format_exc()) showMessage(self._session,_("Can't get settings from profile...", "W", timeout = 10)) except: pass
def enterStandby(self, configElement): log("",self) if not self.isStandby and self.lightsEnabled: Standby.inStandby.onClose.append(self.leaveStandby) self.isStandby = True log("",self,"ControlThread: enterStandby..") self.Control("grabber","sleep")
def writeServer(self): log("", self) self.setStatusBarInfo("writeServer") data = "set threshold 0\n" data += "set mode 0\n" self.sockClass.setCommand(data)
def killEnigmalightFinisched(self, result, retval, extra_args=None): log("", self) (values, callback) = extra_args log("", self, "values " + str(values)) log("", self, "result " + str(result)) log("", self, "retval " + str(retval)) log("", self, "callback " + str(callback)) time.sleep(1) if len(str(result)) == 0: self.setStatusBarInfo(_("Enigmalight killed.")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session, _("Enigmalight killed.", "I")) else: self.setStatusBarInfo(_("Enigmalight not killed!")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage( self.session, _("Enigmalight not killed\nresult: %s") % (str(result)), "I") if callback != None: if self.callbackArgs != None: callback( self.callbackArgs) # now do callback from saved callback else: callback()
def readInfo(self): #log("",self) try: self.serverstate = self.sockClass.getServerState() self.current_mode = str(self.sockClass.getMode()) self.current_fps = str(self.sockClass.getFPS()) self.current_resolution = str(self.sockClass.getRes()) if self.current_mode == "0" and self.serverstate: self.connectedAddres = self.sockClass.getConnectedAddress() else: self.connectedAddres = None except: self.current_fps = "0" self.current_resolution = "0x0" self.current_mode = "Off" self.current_cpu = "0" from traceback import format_exc log("", self, "Error: " + format_exc()) try: open(getCrashFilePath(), "w").write(format_exc()) except: pass
def enterStandby(self, configElement): log("", self) if not self.isStandby and self.lightsEnabled: Standby.inStandby.onClose.append(self.leaveStandby) self.isStandby = True log("", self, "ControlThread: enterStandby..") self.Control("grabber", "sleep")
def __init__(self, session): try: Screen.__init__(self, session) self._session = session self["content"] = Label() self["content2"] = Label() self.controller = None self["statusbar"] = Pixmap() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, }, -2) self.onLayoutFinish.append(self.finishLayout) except: from traceback import format_exc log("",self,"Error:" + format_exc()) try: open(getCrashFilePath(),"w").write(format_exc()) except: pass
def Control(self, command, value, startcommand = "enigmalight -m 0 -f", callback = None): log("",self,"Control: c:%s v:%s" %(command, value)) #Set ConfigFile s_command = startcommand + " -c " + str(config.plugins.enigmalight.configfilepath.value) #Don't use config file for client -> host if config.plugins.enigmalight.network_onoff.value: host = str(config.plugins.enigmalight.address.getText()) port = str(config.plugins.enigmalight.port.getText()) s_command = "enigmalight -s " + host + ":" + port if value == "configtest": s_command = startcommand + " -c /tmp/enigmalight.conf.new" control = { 'command': command, 'value': value, 'startcommand': s_command} if config.plugins.enigmalight.network_onoff.value == True: #self.getPid(control,None,self.checkIfRunningFinisched) #only network mode self.checkIfRunningFinisched(control,None) elif os.path.isfile(str(config.plugins.enigmalight.configfilepath.value)) is True: # getpid and execute command self.checkIfRunning -> DoControl self.checkIfRunningFinisched(control,None) else: showMessage(self.session, elightconf_notfound, "W") self.setStatusBarInfo(_("Configfile not found!"))
def localeInit(): log("",None,"__init__::localeInit()") lang = language.getLanguage() os.environ["LANGUAGE"] = lang[:2] gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE)) gettext.textdomain("enigma2") gettext.bindtextdomain("EnigmaLight", "%s%s" % (resolveFilename(SCOPE_PLUGINS), "Extensions/EnigmaLight/locale/"))
def __init__(self, session): try: Screen.__init__(self, session) self._session = session self["content"] = Label() self["content2"] = Label() self.controller = None self["statusbar"] = Pixmap() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], { "cancel": self.keyCancel, }, -2) self.onLayoutFinish.append(self.finishLayout) except: from traceback import format_exc log("", self, "Error:" + format_exc()) try: open(getCrashFilePath(), "w").write(format_exc()) except: pass
def writeDynamic(self): log("",self) self.setStatusBarInfo(_("writeDynamic")) data ="set threshold " + str(config.plugins.enigmalight.threshold.getValue()) + "\n" data +="set mode 2\n" self.sockClass.setCommand(data)
def Control(self, command, value, startcommand = "enigmalight -m 0 -f", callback = None): log("",self,"Control: c:%s v:%s" %(command, value)) #Set ConfigFile s_command = startcommand + " -c " + str(config.plugins.enigmalight.configfilepath.value) #Don't use config file for client -> host if config.plugins.enigmalight.network_onoff.value: host = str(config.plugins.enigmalight.address.getText()) port = str(config.plugins.enigmalight.port.getText()) s_command = "enigmalight -s " + host + ":" + port if value == "configtest": s_command = startcommand + " -c /tmp/enigmalight.conf.new" control = { 'command': command, 'value': value, 'startcommand': s_command} if config.plugins.enigmalight.network_onoff.value == True: #self.getPid(control,None,self.checkIfRunningFinisched) #only network mode self.checkIfRunningFinisched(control,None) elif os.path.isfile(str(config.plugins.enigmalight.configfilepath.value)) is True: # getpid and execute command self.checkIfRunning -> DoControl self.checkIfRunningFinisched(control,None) else: showMessage(self.session, _(elightconf_notfound), "W") self.setStatusBarInfo(_("Configfile not found!"))
def testConfirmed(self, confirmed): log("",self) if self.test: self.controller.Control("grabber","stop") if confirmed: self.session.openWithCallback(self.MovetoEtc, MessageBox, _("Save this configfile to /etc/ ?"), MessageBox.TYPE_YESNO, timeout = 20, default = True)
def e2restart(self, answer): if answer is True: try: self.session.open(TryQuitMainloop, 3) except Exception, ex: log("",self,"Error: Exception -> " + str(ex)) data = "TryQuitMainLoop is not implemented in your OS.\n Please restart your box manually." self.session.open(MessageBox, _("Information:\n") + data, MessageBox.TYPE_INFO)
def keySave(self): log("", self) #check ip if network is true, before save if config.plugins.enigmalight.network_onoff.getValue(): #check ip if not validIP(str(config.plugins.enigmalight.address.getText())): showMessage( self.session, _("Ip address %s is not accepted, check your input and try again." ) % (str(config.plugins.enigmalight.address.getText())), "W") else: #check connection if not testDaemonConnectivity( config.plugins.enigmalight.address.getText(), config.plugins.enigmalight.port.value): showMessage( self.session, _("Enigmalight can't connect with %s:%s,\ncheck your input and try again." ) % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), "W") else: showMessage( self.session, _("Test Connection with %s:%s, succesfull!") % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), "I") self.saveAll() message = self.session.openWithCallback( self.startClient, MessageBox, _("Do you want to (re)start the client and connect with %s:%s ?" ) % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) else: self.saveAll() if self._hasNetworkChanged: self._hasNetworkChanged = False if self.controller.lightsEnabled: self.controller.killEnigmalight(None, None) message = self.session.openWithCallback( self.startGrabber, MessageBox, _("Do you want to (re)start the client ?"), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) elif self._binTypeChanged: message = self.session.openWithCallback( self.restartEnigmaLight, MessageBox, _("Type of enigmalight has changed, Start this type of Enigmalight ?" ), MessageBox.TYPE_YESNO) message.setTitle(_("Start ?")) else: self.close(None)
def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self.cfglist = [] ConfigListScreen.__init__(self, self.cfglist, session, on_change = self._changed) self._session = session self._hasChanged = False self.version = getVersion() self.controller = None self.selected = None self.sampleUse = False self.aspect = getAspect() self.old_service = self.session.nav.getCurrentlyPlayingServiceReference() self["txt_green"] = Label() self["btn_green"] = Pixmap() self["statusbar"] = Pixmap() self["txt_arrows"] = Label() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["version"] = StaticText() self["txt_green"].setText(_("Save")) self["txt_arrows"].setText(_("Use < > to jump with 10 in slider")) self["version"].text = self.version # Disable OSD Transparency try: self.can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False except: self.can_osd_alpha = False if config.plugins.enigmalight.sampleBackground.getValue() == True: self.showBackground() self["setupActions"] = ActionMap(["SetupActions", "ColorActions", "EL_Settings"], { "green": self.keySave, "cancel": self.exitTuning, "ok": self.ok, "left": self.keyLeft, "right": self.keyRight, "bouquet_up": self.keyBouquetUp, "bouquet_down": self.keyBouquetDown, "jumpNextMark": self.keyNext, "jumpPreviousMark": self.keyPrev, }, -2) self.createSetup() log("",self,"Finisch layout..") #self["config"].onSelectionChanged.append(self.updateHelp) self.onLayoutFinish.append(self.finishLayout)
def cancel(self): log("", self) if self.nextExitIsQuit: self.exit() else: self["menu"].setList(self.menu_main_list) self.nextExitIsQuit = True self.refreshOrientationHorMenu(0)
def refreshMenu(self, s=None): log("", self) self.refreshOrientationHorMenu(0) self.currentScreen = self self.controller.setScreen(self) self.controller.setMainScreen(True) self.controller.sendAll() self.controller.writeSettings()
def getServerState(self): log("E",self,"") ret = self.getCommand("get clientconnected") if ret == "1": ret = True else: ret = False return ret
def getColor(self): log("", self) color = rgbToHex( config.plugins.enigmalight.moodlamp_static_color_r.getValue(), config.plugins.enigmalight.moodlamp_static_color_g.getValue(), config.plugins.enigmalight.moodlamp_static_color_b.getValue()) return color
def getServerState(self): log("E", self, "") ret = self.getCommand("get clientconnected") if ret == "1": ret = True else: ret = False return ret
def updateToLatestVersion(self): remoteUrl = "http://enigmalight.net/updates/enigma2-plugin-extensions-enigmalight_" + str(self.latestVersion) + "_all.ipk" cmd = "opkg install --force-overwrite --force-depends " + str(remoteUrl) log("",self,"remoteUrl: " + str(remoteUrl)) log("",self,"cmd: " + str(cmd)) self.session.open(SConsole,"Executing command:", [cmd] , self.finishupdate)
def exit(self): log("", self, " Main Exit..") self.controller.setSession(None) #Set background session self.controller.setScreen(None) self.controller.setMainScreen(None) self.currentScreen = None self.close((True, ))
def __init__(self, session): log("", self, "Moodlamp Opened succesfull..") Screen.__init__(self, session) HelpableScreen.__init__(self) self.cfglist = [] ConfigListScreen.__init__(self, self.cfglist, session, on_change=self._changed) self._session = session self._hasChanged = False self.selected = None self.controller = None self["txt_green"] = Label() self["txt_yellow"] = Label() self["canvas_text"] = StaticText() self["help"] = StaticText() self["btn_green"] = Pixmap() self["btn_yellow"] = Pixmap() self["statusbar"] = Pixmap() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["Canvas"] = CanvasSource() self["setupActions"] = ActionMap( ["SetupActions", "ColorActions", "EL_Settings"], { "green": self.keySave, "red": self.keyCancel, "cancel": self.keyCancel, "ok": self.ok, "left": self.keyLeft, "right": self.keyRight, "bouquet_up": self.keyBouquetUp, "bouquet_down": self.keyBouquetDown, "jumpNextMark": self.keyNext, "jumpPreviousMark": self.keyPrev, }, -2) self["txt_green"].setText(_("Save")) self["canvas_text"].text = _("Static color:") self.createList() log("", self, "Finisch layout..") self["config"].onSelectionChanged.append(self.updateHelp) self.onLayoutFinish.append(self.finishLayout)
def controlMode(self): log("",self) if config.plugins.enigmalight.mode.value == str(1): data = "set mode " + str(config.plugins.enigmalight.moodlamp_mode.getValue()) +"\n" ret = self.sockClass.setCommand(data) elif config.plugins.enigmalight.mode.value == str(2): data = "set mode 2\n" ret = self.sockClass.setCommand(data) return ret
def setBackground(self): log("Set Canvas bg..", self) self.c = self["Canvas"] r = config.plugins.enigmalight.moodlamp_static_color_r.getValue() g = config.plugins.enigmalight.moodlamp_static_color_g.getValue() b = config.plugins.enigmalight.moodlamp_static_color_b.getValue() #if config.plugins.enigmalight.color_order.getValue() == "0": self.c.fill(0, 0, 950, 30, getRGB(r, g, b))
def keyGreen(self): #Enabled lights log("", self) #self.hideOnOff() self["txt_check"].hide() self["btn_green"].hide() self["txt_green"].hide() self["btn_red"].show() self["txt_red"].show() self.controller.Control("start", "dynamic")
def BJregisterService(protocol, port): log("",None,"EL_HttpServer::BJregisterService()") try: from Plugins.Extensions.Bonjour.Bonjour import bonjour service = bonjour.buildService(protocol, port, 'EnigmalightRemote') bonjour.registerService(service, True) return True except ImportError, e: return False
def setBackground(self): log("Set Canvas bg..",self) self.c = self["Canvas"] r = config.plugins.enigmalight.moodlamp_static_color_r.getValue() g = config.plugins.enigmalight.moodlamp_static_color_g.getValue() b = config.plugins.enigmalight.moodlamp_static_color_b.getValue() #if config.plugins.enigmalight.color_order.getValue() == "0": self.c.fill(0, 0, 950, 30, getRGB(r,g,b))
def __init__(self, session): Screen.__init__(self, session) HelpableScreen.__init__(self) self.cfglist = [] ConfigListScreen.__init__(self, self.cfglist, session, on_change=self._changed) self._session = session self._hasChanged = False self.version = getVersion() self.controller = None self.selected = None self.sampleUse = False self.aspect = getAspect() self.old_service = self.session.nav.getCurrentlyPlayingServiceReference( ) self["txt_green"] = Label() self["btn_green"] = Pixmap() self["statusbar"] = Pixmap() self["txt_arrows"] = Label() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["version"] = StaticText() self["txt_green"].setText(_("Save")) self["txt_arrows"].setText(_("Use < > to jump with 10 in slider")) self["version"].text = self.version # Disable OSD Transparency try: self.can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False except: self.can_osd_alpha = False if config.plugins.enigmalight.sampleBackground.getValue() == True: self.showBackground() self["setupActions"] = ActionMap( ["SetupActions", "ColorActions", "EL_Settings"], { "green": self.keySave, "cancel": self.exitTuning, "ok": self.ok, "left": self.keyLeft, "right": self.keyRight, "bouquet_up": self.keyBouquetUp, "bouquet_down": self.keyBouquetDown, "jumpNextMark": self.keyNext, "jumpPreviousMark": self.keyPrev, }, -2) self.createSetup() log("", self, "Finisch layout..") #self["config"].onSelectionChanged.append(self.updateHelp) self.onLayoutFinish.append(self.finishLayout)
def MovetoEtc(self, confirmed, message = False): log("",self) if confirmed: exists = os.path.isfile("/tmp/enigmalight.conf.new") if exists: os.system("mv /tmp/enigmalight.conf.new /etc/enigmalight.conf") if message: self.session.open(MessageBox, _("enigmalight.conf succesfull saved in /etc/"), MessageBox.TYPE_INFO, timeout=4) self.createfile = False self.test = False
def hideOnOff(self): log("", self) self["btn_green"].hide() self["txt_green"].hide() self["btn_red"].hide() self["txt_red"].hide() self["btn_blue"].hide() self["txt_blue"].hide() self["btn_yellow"].hide() self["txt_yellow"].hide() self["txt_check"].show()
def keyPrev(self): log("",self) self.selected = self["config"].getCurrent()[1] if self.selected == config.plugins.enigmalight.adjustr: config.plugins.enigmalight.adjustr.setValue(Clamp(config.plugins.enigmalight.adjustr.getValue()-10,0,255)) elif self.selected == config.plugins.enigmalight.adjustg: config.plugins.enigmalight.adjustg.setValue(Clamp(config.plugins.enigmalight.adjustg.getValue()-10,0,255)) elif self.selected == config.plugins.enigmalight.adjustb: config.plugins.enigmalight.adjustb.setValue(Clamp(config.plugins.enigmalight.adjustb.getValue()-10,0,255)) self.createSetup() self._changed()
def keyNext(self): log("",self) self.selected = self["config"].getCurrent()[1] if self.selected == config.plugins.enigmalight.moodlamp_static_color_r: config.plugins.enigmalight.moodlamp_static_color_r.setValue(Clamp(config.plugins.enigmalight.moodlamp_static_color_r.getValue()+10,0,255)) elif self.selected == config.plugins.enigmalight.moodlamp_static_color_g: config.plugins.enigmalight.moodlamp_static_color_g.setValue(Clamp(config.plugins.enigmalight.moodlamp_static_color_g.getValue()+10,0,255)) elif self.selected == config.plugins.enigmalight.moodlamp_static_color_b: config.plugins.enigmalight.moodlamp_static_color_b.setValue(Clamp(config.plugins.enigmalight.moodlamp_static_color_b.getValue()+10,0,255)) self._changed() #Refresh list self.createList()
def finishLayout(self): log("",self) self.setTitle(_("Live coloradjustment")) if config.plugins.enigmalight.showstatusbar.value == True: #remove it self["statusbar"].hide() self["txt_statusbar"].hide() self["txt_statusbar_info"].hide() else: self["statusbar"].show() self["txt_statusbar"].show() self["txt_statusbar_info"].show()
def ping(self): log("E",self,"") try: self.sock.send("ping\n") returned = str(self.sock.recv(1024)) log("E",self,"returned: %s " % (returned)) if returned == "ping": return True else: return False except: return None
def __init__(self, session): log("",self,"Moodlamp Opened succesfull..") Screen.__init__(self, session) HelpableScreen.__init__(self) self.cfglist = [] ConfigListScreen.__init__(self, self.cfglist, session, on_change = self._changed) self._session = session self._hasChanged = False self.selected = None self.controller = None self["txt_green"] = Label() self["txt_yellow"] = Label() self["canvas_text"] = StaticText() self["help"] = StaticText() self["btn_green"] = Pixmap() self["btn_yellow"] = Pixmap() self["statusbar"] = Pixmap() self["txt_statusbar"] = Label() self["txt_statusbar_info"] = Label() self["Canvas"] = CanvasSource() self["setupActions"] = ActionMap(["SetupActions", "ColorActions", "EL_Settings"], { "green": self.keySave, "red": self.keyCancel, "cancel": self.keyCancel, "ok": self.ok, "left": self.keyLeft, "right": self.keyRight, "bouquet_up": self.keyBouquetUp, "bouquet_down": self.keyBouquetDown, "jumpNextMark": self.keyNext, "jumpPreviousMark": self.keyPrev, }, -2) self["txt_green"].setText(_("Save")) self["canvas_text"].text = _("Static color:") self.createList() log("",self,"Finisch layout..") self["config"].onSelectionChanged.append(self.updateHelp) self.onLayoutFinish.append(self.finishLayout)
def finishLayout(self): log("",self,"Layout finsched..") self.setBackground() self.setTitle(_("Moodlamp configuration")) if not config.plugins.enigmalight.showstatusbar.getValue(): self["statusbar"].hide() self["txt_statusbar"].hide() self["txt_statusbar_info"].hide() else: self["statusbar"].show() self["txt_statusbar"].show() self["txt_statusbar_info"].show()
def writeAdjust(self): log("",self) self.setStatusBarInfo("writeAdjust") data ="" #only send it to local client if config.plugins.enigmalight.network_onoff.value == False: if config.plugins.enigmalight.use_live_adjust.getValue() == "true": data +="set adjust "+ str(str(config.plugins.enigmalight.adjustr.getValue()) + " " + str(config.plugins.enigmalight.adjustg.getValue()) + " " + str(config.plugins.enigmalight.adjustb.getValue()) + " " + str(config.plugins.enigmalight.use_live_adjust.getValue())) + "\n" else: data +="set adjust "+ str(0) + " " + str(0) + " " + str(0) + " false " + "\n" return data