コード例 #1
0
    def LoadActions(self):
        """ parses the definition specific actions """
        Logger.info(u'Loading Actions for definition:' + self.uDefPublicTitle)
        SetDefinitionContext(self.uName)
        if Globals.oFnAction.Exists():
            sET_Data = CachedFile(Globals.oFnAction)
            sET_Data = ReplaceDefVars(sET_Data, self.oDefinitionVars)
            oET_Root = Orca_FromString(sET_Data, self,
                                       Globals.oFnAction.string)
            Orca_include(oET_Root, orca_et_loader)
            SetDefinitionContext(self.uName)
            Globals.oActions.LoadActionsSub(oET_Root, u'pagestartactions',
                                            u'pagestartaction',
                                            Globals.oActions.dActionsPageStart,
                                            Globals.oFnAction)
            Globals.oActions.LoadActionsSub(oET_Root, u'pagestartactions',
                                            u'pagestopaction',
                                            Globals.oActions.dActionsPageStop,
                                            Globals.oFnAction)
            Globals.oActions.LoadActionsSub(oET_Root, u'actions', u'action',
                                            Globals.oActions.dActionsCommands,
                                            Globals.oFnAction)

            SetVar(uVarName=u'ORCASTANDARDPAGESTARTACTIONSINCLUDED',
                   oVarValue=u"1")
            SetVar(uVarName=u'ORCASTANDARDACTIONSINCLUDED', oVarValue=u"1")
        RestoreDefinitionContext()
        return
コード例 #2
0
    def LoadScriptList(self, oPath=None):
        """ loads a list of all scripts """

        if oPath is None:
            oPath = Globals.oPathScripts

        if oPath == Globals.oPathScripts:
            Logger.debug(u'Scripts: Loading Script List')

        aScriptNameList = oPath.GetFolderList()
        for uScriptNameFolder in aScriptNameList:
            oFolderPath = cPath(oPath) + uScriptNameFolder
            if (cFileName(oFolderPath) + "script.py").Exists():
                self.aScriptNameList.append(uScriptNameFolder)
                self.dScriptPathList[uScriptNameFolder] = oFolderPath
            else:
                self.LoadScriptList(oPath=oFolderPath)

        if oPath == Globals.oPathScripts:
            self.aScriptNameList.sort(key=lambda x: x)

            for uScriptName in self.aScriptNameList:
                SetVar(uVarName="SCRIPTPATH[%s]" % uScriptName,
                       oVarValue=self.dScriptPathList[uScriptName].string)
                oPathScriptSkinElements = self.dScriptPathList[
                    uScriptName] + "elements"
                oPathCheck = oPathScriptSkinElements + ("skin_" +
                                                        Globals.uSkinName)
                if oPathCheck.Exists():
                    oPathScriptSkinElements = oPathCheck
                else:
                    oPathScriptSkinElements = oPathScriptSkinElements + "skin_default"

                SetVar(uVarName="SCRIPTPATHSKINELEMENTS[%s]" % (uScriptName),
                       oVarValue=oPathScriptSkinElements.string)
コード例 #3
0
    def InitOrientationVars(self):
        """
        Getting the orientation of the App and sets to system vars for it
        """
        # noinspection PyProtectedMember
        Logger.debug(
            u'Setting Orientation Variables #1: Screen Size: [%s], Width: [%s], Heigth: [%s], Orientation: [%s]'
            %
            (str(Globals.fScreenSize), str(self._app_window._size[0]),
             str(self._app_window._size[1]), str(Globals.uDeviceOrientation)))

        OS_GetWindowSize()

        if Globals.iAppWidth < Globals.iAppHeight:
            Globals.uDeviceOrientation = 'portrait'
        else:
            Globals.uDeviceOrientation = 'landscape'

        Globals.oRotation.Lock()

        SetVar(uVarName=u'DEVICEORIENTATION',
               oVarValue=Globals.uDeviceOrientation)
        SetVar(uVarName=u'SCREENSIZE', oVarValue=str(Globals.fScreenSize))

        Logger.debug(
            u'Setting Orientation Variables: Screen Size: [%s], Width: [%s], Heigth: [%s], Orientation: [%s]'
            % (str(Globals.fScreenSize), str(Globals.iAppWidth),
               str(Globals.iAppHeight), str(Globals.uDeviceOrientation)))
コード例 #4
0
ファイル: BaseConfig.py プロジェクト: thica/ORCA-Remote
 def On_ConfigChange(self, oSettings: KivySettings,
                     oConfig: KivyConfigParser, uSection: str, uKey: str,
                     uValue: str):
     """ reacts, if user changes a setting """
     if uKey == u'configchangebuttons':
         self.uCurrentSection = uSection
         if uValue == u'button_add':
             SetVar(uVarName=u'SCRIPTINPUT', oVarValue=u'DEVICE_dummy')
             self.oInputKeyboard = ShowKeyBoard(uDestVar=u'SCRIPTINPUT',
                                                oFktNotify=self.On_InputAdd)
         if uValue == u'button_delete':
             ShowQuestionPopUp(uTitle=u'$lvar(5003)',
                               uMessage=u'$lvar(5044)',
                               fktYes=self.On_InputDel,
                               uStringYes=u'$lvar(5001)',
                               uStringNo=u'$lvar(5002)')
         if uValue == u'button_rename':
             SetVar(uVarName=u'SCRIPTINPUT', oVarValue=uSection)
             self.oInputKeyboard = ShowKeyBoard(uDestVar=u'SCRIPTINPUT',
                                                oFktNotify=self.On_InputRen)
     else:
         oSetting = self.oObject.GetSettingObjectForConfigName(
             uConfigName=uSection)
         if uKey in self.dSettingsCombined:
             uType = self.dSettingsCombined[uKey].get("type")
             if uType == "numeric" or uType == "numericslider":
                 oSetting.aIniSettings[uKey] = ToInt(uValue)
             elif uType == "numericfloat":
                 oSetting.aIniSettings[uKey] = ToFloat(uValue)
             elif uType == "bool":
                 oSetting.aIniSettings[uKey] = ToBool(uValue)
             else:
                 oSetting.aIniSettings[uKey] = uValue
コード例 #5
0
 def On_Definition_ConfigChange(self, settings, config, section, key,
                                value):
     """ Called, when a setting has been changed, will set the associated var as well """
     if key in Globals.oDefinitions.aDefinitionSettingVars:
         if value.startswith("button_"):
             SetVar(uVarName=key, oVarValue=str(random()))
         else:
             SetVar(uVarName=key, oVarValue=value)
コード例 #6
0
ファイル: Definition.py プロジェクト: thica/ORCA-Remote
    def LoadXMLFile(self) -> bool:
        """ The main function to load the xml """

        SetDefinitionContext(uDefinitionName=self.uName)
        Globals.oTheScreen.LogToSplashScreen2(uText=self.uDefDescription)
        Logger.info(u'Loading definition XmlFile:' +
                    Globals.oDefinitionPathes.oFnDefinition)

        oET_Root: Element = self.oET_Root
        try:
            Logger.debug(u'Definition %s (%s): Loading xml includes' %
                         (self.uName, self.uAlias))
            Orca_include(
                oElem=oET_Root,
                pLoader=orca_et_loader,
                uFileName=Globals.oDefinitionPathes.oFnDefinition.string)
            SetDefinitionContext(uDefinitionName=self.uName)
        except Exception as e:
            StartWait()
            ShowErrorPopUp(
                uTitle="LoadXMLFile:Fatal Error",
                uMessage=LogError(
                    uMsg=u'Fatal Error: definition xml file faulty:' +
                    self.uName,
                    oException=e),
                bAbort=True)

        SetVar(uVarName='ORCASTANDARDPAGESINCLUDED', oVarValue="1")

        Globals.oTheScreen.uDefName = self.oRepManEntry.oRepEntry.uName
        self.oDefinitions.uDefinitionAuthor = self.oRepManEntry.oRepEntry.uAuthor
        self.oDefinitions.uDefinitionVersion = self.oRepManEntry.oRepEntry.uVersion
        SetVar(uVarName=u'DEFINITIONAUTHOR',
               oVarValue=self.oDefinitions.uDefinitionAuthor)
        SetVar(uVarName=u'DEFINITIONVERSION',
               oVarValue=self.oDefinitions.uDefinitionVersion)
        SetVar(uVarName=u'DEFINITIONSUPPORT',
               oVarValue=self.oDefinitions.uDefinitionSupport)

        Logger.debug(u'Definition [%s] : Ratios %fx%f:' %
                     (self.uName, self.fRationX, self.fRationY))
        if self.bImportPages:
            # get a list of all pages and add Them
            oXMLPages: Element = oET_Root.find('pages')
            for oXMLPage in oXMLPages.findall('page'):
                Globals.oTheScreen.oScreenPages.AddPageFromXmlNode(
                    oXMLPage=oXMLPage)
            oXMLPageImport: Element = oXMLPages.find('pageimport')
            if oXMLPageImport is not None:
                for oXMLPage in oXMLPageImport.findall('page'):
                    Globals.oTheScreen.oScreenPages.AddPageFromXmlNode(
                        oXMLPage=oXMLPage)

            Globals.oNotifications.SendNotification(
                uNotification="DEFINITIONPAGESLOADED", **{"definition": self})
        RestoreDefinitionContext()

        return True
コード例 #7
0
    def AppendToPageQueue(self, oPage):
        """  Appends a Page to the list of last shown pages"""
        if GetVar(uVarName=u'FIRSTPAGE') == u'':
            SetVar(uVarName=u'FIRSTPAGE', oVarValue=oPage.uPageName)
        SetVar(uVarName=u'CURRENTPAGE', oVarValue=oPage.uPageName)

        self.aPageQueue.append(oPage)
        if len(self.aPageQueue) > 1:
            SetVar(uVarName=u'LASTPAGE',
                   oVarValue=self.aPageQueue[-2].uPageName)
コード例 #8
0
ファイル: Switch.py プロジェクト: thica/ORCA-Remote
 def InvertSwitch(self, instance: Union[cTouchButton, None]) -> None:
     """ Inverts and button and the var """
     if GetVar(uVarName=self.uDestVar) == '1':
         SetVar(uVarName=self.uDestVar, oVarValue='0')
         self.SetPictureNormal(self.oFnButtonPictureNormalOrg.string, True)
         self.SetPicturePressed(self.oFnButtonPicturePressedOrg.string)
     else:
         SetVar(uVarName=self.uDestVar, oVarValue='1')
         self.SetPictureNormal(self.oFnButtonPicturePressedOrg.string, True)
         self.SetPicturePressed(self.oFnButtonPictureNormalOrg.string)
コード例 #9
0
    def AssignChannels(self, **kwargs):
        """
        Sets the TV Logos for the parsed channels

        :param kwargs: argument dic, need to have definitionalias, interface, configname, force
        """
        try:
            uAlias = ReplaceVars(kwargs['definitionalias'])
            uInterfaceName = ReplaceVars(kwargs['interface'])
            uConfigName = ReplaceVars(kwargs['configname'])
            bForce = ReplaceVars(kwargs['force']) != '0'
            oInterFace = Globals.oInterFaces.dInterfaces.get(uInterfaceName)
            oSetting = oInterFace.GetSettingObjectForConfigName(uConfigName)
            uContext = oSetting.uContext
            uSection = Globals.uDefinitionName

            dServices = self.dServices.get(uContext, {})
            aBouquets = dServices.get("Bouquets", [])
            for dBouquetDetail in aBouquets:
                iBouquetNumber = dBouquetDetail["BouquetNum"]
                if iBouquetNumber < 5:
                    uBouquetName = dBouquetDetail["Name"]
                    uVarName = uAlias + "_bouquet_name[" + str(
                        iBouquetNumber) + "]"
                    uVarValue = uBouquetName
                    Globals.oDefinitionConfigParser.set(
                        uSection, uVarName, EscapeUnicode(uVarValue))
                    SetVar(uVarName=uVarName, oVarValue=uVarValue)
                    dChannels = dBouquetDetail.get("Channels", {})
                    for iBouquetChannelNum in dChannels:
                        if iBouquetChannelNum < 30:
                            dChannel = dChannels[iBouquetChannelNum]
                            uVarName = uAlias + "%s[%d][%d]" % (
                                "_tvlogo", iBouquetNumber, iBouquetChannelNum)
                            if Globals.oDefinitionConfigParser.get(
                                    uSection,
                                    uVarName) == "discover" or bForce:
                                uVarValue = self.FindChannelLogo(
                                    dChannel["ChannelName"])
                                Globals.oDefinitionConfigParser.set(
                                    uSection, uVarName,
                                    EscapeUnicode(uVarValue))
                                SetVar(uVarName=uVarName, oVarValue=uVarValue)
                                uVarName = uAlias + "%s[%d][%d]" % (
                                    "_tvchannel", iBouquetNumber,
                                    iBouquetChannelNum)
                                uVarValue = str(dChannel["ChannelNum"])
                                Globals.oDefinitionConfigParser.set(
                                    uSection, uVarName, uVarValue)
                                SetVar(uVarName=uVarName, oVarValue=uVarValue)

            Globals.oDefinitionConfigParser.write()

        except Exception as e:
            self.ShowError("Can''t assign channelnumbers", e)
コード例 #10
0
    def On_Color_Wheel(self, *largs):
        """ updates the deasvars, of the colorpicker color has changed """
        instance=self.oObjectColorPicker
        self.fValue = instance.hex_color
        if self.uDestVar:
            SetVar(uVarName = self.uDestVar, oVarValue = self.fValue )
            SetVar(uVarName = self.uDestVar+"_hex", oVarValue = self.fValue )
            h,s,v=instance.hsv[0],instance.hsv[1],instance.hsv[2]

            SetVar(uVarName = self.uDestVar+"_h", oVarValue = str(int(h*255)))
            SetVar(uVarName = self.uDestVar+"_s", oVarValue = str(int(s*255)))
            SetVar(uVarName = self.uDestVar+"_v", oVarValue = str(int(v*255)))

            SetVar(uVarName = self.uDestVar+"_r", oVarValue = str(int(instance.color[0]*255) ))
            SetVar(uVarName = self.uDestVar+"_g", oVarValue = str(int(instance.color[1]*255) ))
            SetVar(uVarName = self.uDestVar+"_b", oVarValue = str(int(instance.color[2]*255) ))
            SetVar(uVarName = self.uDestVar+"_a", oVarValue = str(int(instance.color[3]*255) ))

            Logger.debug("Setting Var:"+self.uDestVar+"="+str(self.fValue))
            Logger.debug("Setting Var:"+self.uDestVar+"_hex"+"="+str(self.fValue))
            Logger.debug("Setting Var:"+self.uDestVar+"_h"+"="+str(str(int(h*255))))
            Logger.debug("Setting Var:"+self.uDestVar+"_s"+"="+str(str(int(s*255))))
            Logger.debug("Setting Var:"+self.uDestVar+"_v"+"="+str(str(int(v*255))))

            Logger.debug("Setting Var:"+self.uDestVar+"_r"+"="+str(int(instance.color[0]*255)))
            Logger.debug("Setting Var:"+self.uDestVar+"_g"+"="+str(int(instance.color[1]*255)))
            Logger.debug("Setting Var:"+self.uDestVar+"_b"+"="+str(int(instance.color[2]*255)))
            Logger.debug("Setting Var:"+self.uDestVar+"_a"+"="+str(int(instance.color[3]*255)))

            #SetVar(self.uDestVar+"_rgba",instance.color)

        if self.uActionName:
            if self.fOldValue != self.fValue:
                self.fOldValue = self.fValue
                self.On_Button_Up(instance)
コード例 #11
0
ファイル: RepManager.py プロジェクト: thica/ORCA-Remote
    def CreateRepVarArray(self,uBaseLocalDir:str) -> None:
        aLocalFiles:List[str] = cPath(uBaseLocalDir).GetFileList(bSubDirs=True, bFullPath=True)
        SetVar(uVarName="REPMAN_LOCALBASENAME", oVarValue=uBaseLocalDir)
        SetVar(uVarName="REPMAN_CNTFILES",      oVarValue= str(len(aLocalFiles)))
        Var_DelArray("REPMAN_LOCALFILENAMES[]")

        i:int=0
        for uLocalFile in aLocalFiles:
            uIndex:str = str(i) + "]"
            SetVar(uVarName="REPMAN_LOCALFILENAMES[" + uIndex ,oVarValue=uLocalFile)
            i += 1
コード例 #12
0
 def UpdateVars(self) -> None:
     """ updates the destination vars """
     if not self.uDestVar == u'':
         SetVar(uVarName=self.uDestVar, oVarValue=ToUnicode(self.fValue))
         if self.oObject:
             SetVar(uVarName=self.uDestVar + u'_degree',
                    oVarValue=ToUnicode(self.oObject.iAngle))
             SetVar(uVarName=self.uDestVar + u'_direction',
                    oVarValue=ToUnicode(self.oObject.uDirection))
         SetVar(uVarName=self.uDestVar + u'_absdegree',
                oVarValue=ToUnicode(self.iAbsAngle))
コード例 #13
0
ファイル: DefinitionPathes.py プロジェクト: thica/ORCA-Remote
    def __init__(self, *,uDefinitionName:str, uDefinitionPathName:str=u"") -> None:
        uAdd:str
        self.oPathDefinition:cPath
        self.oPathDefinitionSkinElements:cPath
        oPathCheck:cPath
        uCheck:str

        if Globals.uDeviceOrientation == 'landscape':
            uAdd = 'l'
        else:
            uAdd = 'p'
        if Globals.fScreenSize<5.1:
            uAdd += 's'
        else:
            uAdd += 'l'

        if uDefinitionPathName==u"":
            self.oPathDefinition = Globals.oPathDefinitionRoot + uDefinitionName
        else:
            self.oPathDefinition = Globals.oPathDefinitionRoot + uDefinitionPathName

        self.oPathDefinitionAtlas:cPath                 = self.oPathDefinition + 'atlas'
        self.oFnDefinitionAtlas:cFileName               = cFileName(self.oPathDefinitionAtlas) + u'definition.atlas'
        self.oFnDefinitionLocalFont:cFileName           = cFileName(self.oPathDefinition + u'fonts') + 'fonts.xml'
        self.oFnDefinition:cFileName                    = cFileName(self.oPathDefinition) + u'definition.xml'
        self.oFnDefinitionCache:cFileName               = cFileName(self.oPathDefinition) + (u'cache_' + uAdd + '.xml')
        self.oFnDefinitionIni:cFileName                 = cFileName(self.oPathDefinition) + u'definition.ini'
        self.oPathDefinitionInterfaceSettings:cPath     = self.oPathDefinition + u'interfacesettings'
        self.oPathDefinitionScriptSettings:cPath        = self.oPathDefinition + u'scriptsettings'
        self.oFnDefinitionLanguage:cFileName            = cFileName()
        self.oFnDefinitionLanguageFallBack:cFileName    = cFileName(self.oPathDefinition + u'languages/English')+ "strings.xml"
        self.oPathDefinitionSkinElements:cPath          = self.oPathDefinition + u'elements'
        self.oPathTemplateSkinElements:cFileName        = cFileName()

        uCheck = "skin_" + Globals.uSkinName
        oPathCheck = self.oPathDefinitionSkinElements + uCheck
        if oPathCheck.Exists():
            self.oPathDefinitionSkinElements = oPathCheck
            SetVar("SKINCONTEXT",uCheck)
        else:
            self.oPathDefinitionSkinElements = self.oPathDefinitionSkinElements + "skin_default"
            SetVar("SKINCONTEXT", "skin_default")

        self.LanguageChange()

        if uDefinitionName in Globals.oDefinitions:
            if "definition_templatename_mediaplayer_wizard" in Globals.oDefinitions[uDefinitionName].oDefinitionVars:
                oPathCheck = Globals.oPathWizardTemplates +(Globals.oDefinitions[uDefinitionName].oDefinitionVars["definition_templatename_mediaplayer_wizard"]+"/elements/" +uCheck)
                if oPathCheck.Exists():
                    self.oPathTemplateSkinElements = oPathCheck
                    SetVar("MEDIATEMPLATESKINCONTEXT",uCheck)
                else:
                    self.oPathDefinitionSkinElements = Globals.oPathWizardTemplates +(Globals.oDefinitions[uDefinitionName].oDefinitionVars["definition_templatename_mediaplayer_wizard"]+"/elements/" + "skin_default")
                    SetVar("MEDIATEMPLATESKINCONTEXT", "skin_default")
コード例 #14
0
ファイル: Settings.py プロジェクト: thica/ORCA-Remote
 def On_Orca_ConfigChange(self, settings: Settings, config: ConfigParser,
                          section: str, key: str, value: str) -> None:
     """ Called, when a setting has been changed, will set the associated var as well """
     if value.startswith("button_"):
         SetVar(uVarName=key, oVarValue=str(random()))
     else:
         SetVar(uVarName=key, oVarValue=value)
     OrcaConfigParser_On_Setting_Change(config=config,
                                        section=section,
                                        key=key,
                                        value=value)
コード例 #15
0
 def _SetVar(self,uValue,uDebugMessage,uAddName=u''):
     """ Sets the vars, which contains the parse results """
     if self.uLocalDestVar != u'':
         self.ShowDebug(u'Local: %s : [%s]=[%s]' % (uDebugMessage,self.uLocalDestVar+uAddName,uValue))
         SetVar(uVarName = self.uLocalDestVar+uAddName, oVarValue = uValue, uContext = self.uContext)
     if self.uGlobalDestVar != u'':
         if self.uGlobalDestVar.startswith("$var("):
             self.uGlobalDestVar=ReplaceVars(self.uGlobalDestVar)
         self.ShowDebug(u'Global: %s : [%s]=[%s]' %(uDebugMessage,self.uGlobalDestVar+uAddName,uValue))
         SetVar(uVarName = self.uGlobalDestVar+uAddName, oVarValue = uValue)
         SetVar(uVarName = "RESULT", oVarValue = uValue)
         SetVar(uVarName = "GLOBALDESTVAR", oVarValue = self.uGlobalDestVar+uAddName)
コード例 #16
0
def SetDefinitionPathes(uDefinitionName, uDefinitionPathName=u''):
    """
    Sets the definition pathes to a specific definition
    """
    if not uDefinitionName in Globals.dDefinitionPathes:
        oDefinitionPathes = cDefinitionPathes(uDefinitionName, uDefinitionPathName)
        Globals.dDefinitionPathes[uDefinitionName] = oDefinitionPathes

    Globals.oDefinitionPathes = Globals.dDefinitionPathes[uDefinitionName]

    SetVar(uVarName=u'DEFINITIONPATH',                  oVarValue=Globals.oDefinitionPathes.oPathDefinition.string)
    SetVar(uVarName=u'DEFINITIONFILENAME',              oVarValue=Globals.oDefinitionPathes.oFnDefinition.string)
    SetVar(uVarName=u'DEFINITIONNAME',                  oVarValue=Globals.uDefinitionName)
    SetVar(uVarName=u'DEFINITIONPATHSKINELEMENTS',      oVarValue=Globals.oDefinitionPathes.oPathDefinitionSkinElements.string)
コード例 #17
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Round(uVarName: str, uPos: str) -> str:
    """
    Rounds a var value to the given round position.
    The changed variable value will be return and stored in the user vars (Triggers raised if set)
    Example: Round(1.81,0) return 2. Round(1.81,1) returns 1.80

    :param str uVarName: The variable name for the action, from where the value is pulled
    :param str uPos: The round position
    :return: The changed variable value
    """

    uValue: str = GetVar(uVarName=uVarName)

    try:
        if uValue == u'':
            return u''

        uPosToUse: str = GetVar(uVarName=uPos)
        if uPosToUse == u'':
            uPosToUse = uPos
        iPos: int = int(uPosToUse)
        uValue = ToUnicode(Round(ToFloat(uValue), iPos))
        SetVar(uVarName=uVarName, oVarValue=uValue)
        return uValue

    except Exception as e:
        LogError(uMsg=u'Var_Round: Invalid Argument [' + uVarName + u'=' +
                 uValue + u']:',
                 oException=e)
        return u'Error'
コード例 #18
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Power(uVarName: str, uPower: str) -> str:
    """
    Exponentiate a given variable value.
    The changed variable value will be return and stored in the user vars (Triggers raised if set)

    :param str uVarName: The variable name for the action, from where the value is pulled
    :param str uPower: The value to exponentiate the original value with, can be a variable itself
    :return: The changed variable value
    """

    try:
        uValue: str = GetVar(uVarName=uVarName)
        uValueOrg: str = uValue
        if uValue == u'':
            return u''

        uPowerToUse: str = GetVar(uVarName=uPower)
        if uPowerToUse == u'':
            uPowerToUse = uPower
        uPowerToUse = ReplaceVars(uPowerToUse)
        fPower: float = ToFloat(uPowerToUse)
        fValue: float = ToFloat(uValue)
        fValue = fValue**fPower
        uValue = ToUnicode(fValue)
        uValue = Var_NormalizeInt(uValue)
        SetVar(uVarName=uVarName, oVarValue=uValue)
        Logger.debug(
            u'Var_Power: [%s] ^ [%s] returned [%s]  (stored in [%s])' %
            (uValueOrg, uPowerToUse, uValue, uVarName))
        return uValue
    except Exception as e:
        LogError(uMsg=u'Var_Power: Invalid Argument', oException=e)
        return u'Error'
コード例 #19
0
    def ReplaceElement(self, uFnElement, uReplaceWidgetName, oDefinition):
        """ Replaces an element at runtime in a page: the page must not be initalized
        :param string uFnElement: FileName of element to load
        :param string uReplaceWidgetName: The Widgetname to be replaced
        :param cDefinition oDefinition: Target Definition
        :rtype: bool
        :return: True if successful, otherwise False

        """

        uFnFile = ''

        try:
            uFnFile = (cFileName(u'').ImportFullPath(uFnElement)).string
            SetVar(uVarName='ORCA_INCLUDEFILE', oVarValue=uFnFile)
            if oDefinition is None:
                oDef = self.oWidgetBackGround.oDef
            else:
                oDef = oDefinition
            sET_Data = CachedFile(Globals.oFnElementIncludeWrapper)
            sET_Data = ReplaceDefVars(sET_Data, oDef.oDefinitionVars)
            oET_Root = Orca_FromString(sET_Data, oDef, uFnFile)
            Orca_include(oET_Root, orca_et_loader)
            self._ReplaceElements(oXMLNode=oET_Root,
                                  uReplaceWidgetName=uReplaceWidgetName)
            return True
        except Exception as e:
            uMsg = LogError(
                "Can''t load element (replace): %s (%s):" %
                (uFnElement, uFnFile), e)
            ShowErrorPopUp(uMessage=uMsg)
            return False
コード例 #20
0
    def CallTrigger(self, oTrigger: cBaseTrigger, uResponse: str) -> None:
        """
        calls a trigger

        :param cBaseTrigger oTrigger: The trigger object
        :param str uResponse: The response of the trigger action
        :return: None
        """
        # if oTrigger.uTriggerAction=='':
        #    self.ShowWarning(u'No Trigger Action defined for Trigger:' + oTrigger.uTriggerName)
        #    # return

        self.ShowDebug(uMsg=oTrigger.uTriggerName + ":"
                       u'Trigger Action:' + oTrigger.uTriggerAction)

        uCmd: str
        vRetVal: Union[str, Tuple]
        uRetVal: str
        oAction: Union[None, cAction] = None

        if oTrigger.uGetVar.startswith(u'codesetcode:'):
            uActionName: str = self.MakeLocalActionName(oTrigger.uGetVar[12:])
            aActions: List[cAction] = Globals.oActions.GetActionList(
                uActionName=uActionName, bNoCopy=False)
            if aActions is not None:
                oAction = aActions[0]
                if oAction.uGetVar != u'':
                    oTrigger.uGetVar = oAction.uGetVar
                if oAction.uGlobalDestVar != u'':
                    oTrigger.uRetVar = oAction.uGlobalDestVar
                oTrigger.uTriggerName = oAction.uCmd

        if oAction is None:
            if self.oAction:
                oAction = copy(self.oAction)
            else:
                oAction = copy(self.oLastAction)

        oAction.uActionName = oTrigger.uTriggerAction
        oAction.uGetVar = oTrigger.uGetVar
        oAction.uGlobalDestVar = oTrigger.uRetVar

        #We call ParseResult to set the Values to proper Global Vars
        uCmd, vRetVal = self.oInterFace.ParseResult(oAction, uResponse, self)
        if isinstance(vRetVal, tuple):
            uRetVal = vRetVal[0]
        else:
            uRetVal = vRetVal

        if oTrigger.uRetVar != u'' and uRetVal != u'':
            SetVar(uVarName=oTrigger.uRetVar, oVarValue=uRetVal)
        if oAction.uActionName != u'':
            aActions = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'string': 'call',
                    'actionname': oTrigger.uTriggerAction,
                    'name': oAction.uActionName
                }])
            Globals.oEvents.ExecuteActionsNewQueue(
                aActions, Globals.oTheScreen.oCurrentPage.oWidgetBackGround)
コード例 #21
0
 def __init__(self):
     oInterFaceTelnet.cInterface.__init__(self)
     self.aTargets = {
         '0': 'TV',
         '1': 'Recording 1',
         '2': 'Recording 2',
         '3': 'Tuner 1',
         '4': 'Playback 1',
         '5': 'Audio system',
         '6': 'Tuner 2',
         '7': 'Tuner 3',
         '8': 'Playback 2',
         '9': 'Playback 3',
         'A': 'Tuner 4',
         'B': 'Playback 3',
         'C': 'Reserved (C)',
         'D': 'Reserved (D)',
         'E': 'Reserved (E)',
         'F': 'Unregistered'
     }
     uValueString = u''
     for uKey in self.aTargets:
         uValueString += u'\"' + self.aTargets[uKey] + u'\",'
     uValueString = uValueString[1:-2]
     SetVar(uVarName="VALUESTRING", oVarValue=uValueString)
コード例 #22
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Int2Hex(uVarName: str, uFormat: str = '{0:0>2X}') -> str:
    """
    Converts a Variable which represents an int value to a string of a hex value
    The changed variable value will be return and stored in the user vars (Triggers raised if set)

    :param str uVarName: The variable name for the action, from where the value is pulled
    :param str uFormat: The format to use for the conversion
    :return: The changed variable value
    """

    uValue: str = GetVar(uVarName=uVarName)
    try:

        if uValue == '':
            return u'0'
        if uValue == 'Error':
            return u'0'

        uValue = uFormat.format(int(uValue))
        uValue = ToUnicode(uValue)
        SetVar(uVarName=uVarName, oVarValue=uValue)
        return uValue
    except Exception as e:
        LogError(uMsg=u'Var_Int2Hex: Invalid Argument (%s):' % uValue,
                 oException=e)
        return u'0'
コード例 #23
0
ファイル: Queue.py プロジェクト: thica/ORCA-Remote
    def WorkOnQueueDoAction(self, *,
                            oAction: cAction) -> Union[eReturnCode, int]:
        """ Executes a single action in a queue (including condition verifying)"""

        eRet: eReturnCode = eReturnCode.Success
        bCheckSuccess: bool = CheckCondition(oPar=oAction)

        if oAction.iActionId == Globals.oActions.oActionType.If:
            # we do the If statement only in case of the condition fails
            if bCheckSuccess:
                Globals.oEvents.LogAction(uTxt="if",
                                          oAction=oAction,
                                          uAddText="executing actions")
            # we need to run the if command in any way to skip the actions
            bCheckSuccess = not bCheckSuccess

        if bCheckSuccess:
            #We set / replace Action Command Pars by Definition/Button pars
            eRet = self.ExecuteAction(oAction=oAction)
            if eRet != eReturnCode.Nothing:
                SetVar(uVarName=u'LASTERRORCODE', oVarValue=ToUnicode(eRet))
                if eRet != eReturnCode.Success:
                    Logger.debug("Action returned LASTERRORCODE " +
                                 ToUnicode(eRet))
        return eRet
コード例 #24
0
ファイル: Screen.py プロジェクト: thica/ORCA-Remote
    def InitVars(self) -> None:
        """ (re) Initialises all vars (also after a definition change) """
        InitSystemVars()
        Globals.oDefinitions.InitVars()
        SetVar(uVarName = u'REPVERSION', oVarValue = ToUnicode(Globals.iVersion))

        # Name of the Current page
        # List for settings dialog
        self.bIntransition              = False
        self.dGestures.clear()
        self.dPopups.clear()
        self.iLastWidgetPage            = 0
        Globals.oActions.InitVars()
        self.oCurrentPage               = None
        self.oFonts.DeInit()
        self.oGdb                       = GestureDatabase()
        self.oPopup                     = None
        self.oScreenPages.DeInit()
        self.uCurrentEffect             = u''
        self.uCurrentEffectDirection    = u''
        self.uCurrentPageName           = u''
        self.uDefaultTransmitterPictureName = u''
        self.uDefaultWaitPictureName    = u''
        self.uDefName                   = u''
        self.uFirstPageName             = u''
        self.uInterFaceToConfig         = u''
        self.uScriptToConfig            = u''
        self.uConfigToConfig            = u''
        self.uSplashText                = u''
        self.iBlockCount                = 0
        self.iBlockAskCount             = 0
        if Globals.oTheScreen:
            Globals.oTheScreen.oSkin.dSkinRedirects.clear()
        gc.collect()
コード例 #25
0
        def Receive(self, uResponse: str):
            aActionTrigger: Optional[List[cBaseTrigger]]
            uResponse = ToUnicode(uResponse)
            if self.oAction is not None:
                uCmd, uRetVal = self.oInterFace.ParseResult(
                    self.oAction, uResponse, self)
                self.ShowDebug(uMsg=u'Parsed Responses:' + uRetVal)
                if not self.uRetVar == u'' and not uRetVal == u'':
                    SetVar(uVarName=self.uRetVar, oVarValue=uRetVal)
                # We do not need to wait for an response anymore
                StartWait(0)
                self.oAction = None
            else:
                oAction: cAction = self.dStandardActions["defaultresponse"]
                if oAction:
                    uCommand = self.oInterFace.ParseResult(
                        oAction, uResponse, self)
                    if not isinstance(uCommand, str):
                        if len(uCommand) > 0:
                            uCommand = uCommand[1]

                    # we have a notification issued by the device, so lets have a look, if we have a trigger assigned to it
                    aActionTrigger = self.GetTrigger(uCommand)
                    if aActionTrigger is not None:
                        for oActionTrigger in oActionTrigger:
                            self.CallTrigger(oActionTrigger, uResponse)
                    else:
                        self.ShowDebug(uMsg=u'Discard message:' + uCommand +
                                       ':' + uResponse)
コード例 #26
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Part(uVarName: str, uStart: str, uEnd: str) -> str:
    """
    Extracts a part of a variable value.
    The changed variable value will be return and stored in the user vars (Triggers raised if set)

    :param str uVarName: The variable name for the action, from where the value is pulled
    :param str uStart: The start position within the var value
    :param str uEnd: The end position within the var value
    :return: The changed variable value
    """

    try:
        uValue: str = GetVar(uVarName=uVarName)
        if uValue == u'':
            return u''
        if not uStart == '':
            if not uEnd == '':
                uValue = uValue[int(uStart):int(uEnd)]
            else:
                uValue = uValue[int(uStart):]
        else:
            uValue = uValue[:int(uEnd)]
        SetVar(uVarName=uVarName, oVarValue=uValue)
        return uValue
    except Exception as e:
        LogError(uMsg='Var_Part: Invalid Argument', oException=e)
        return u'Error'
コード例 #27
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Hex2Int(uVarName: str) -> str:
    """
    Converts a Variable which represents an hex value to a string of an Int value
    The changed variable value will be return and stored in the user vars (Triggers raised if set)

    :param str uVarName: The variable name for the action, from where the value is pulled
    :return: The changed variable value
    """

    uValue: str = GetVar(uVarName=uVarName)
    try:
        if uValue == '':
            return u'0'
        if uValue == 'Error':
            return u'0'

        if uValue.lower().startswith('0x'):
            iValue = int(uValue, 0)
        else:
            iValue = int(uValue, 16)

        uValue = ToUnicode(iValue)
        uValue = Var_NormalizeInt(uValue)
        SetVar(uVarName=uVarName, oVarValue=uValue)
        return uValue
    except Exception as e:
        LogError(uMsg=u'Var_Hex2Int: Invalid Argument (%s):' % uValue,
                 oException=e)
        return u'0'
コード例 #28
0
def BuildSettingOptionListVar(aArray: Iterable[str], uDestVar: str) -> str:
    """
    Little helper function to create a json option list
    """
    uValueString = "[" + BuildSettingOptionList(aArray) + "]"
    SetVar(uDestVar, uValueString)
    return uValueString
コード例 #29
0
ファイル: Actions.py プロジェクト: thica/ORCA-Remote
def Var_Format(uVarName: str, uFormat: str):
    """
    Formats a variable content to a given format
    The changed variable value will be return and stored in the user vars (Triggers raised if set)

    :param str uVarName: The variable name for the action, from where the value is pulled
    :param str uFormat: The format to use (python syntax)
    :return: The changed variable value
    """

    try:
        uValue: str = GetVar(uVarName=uVarName)
        if uValue is None:
            return u''
        uFormatToUse: str = ORCA.vars.Globals.dUserVars.get(uFormat)
        if uFormatToUse is None:
            uFormatToUse = uFormat

        if uFormatToUse.startswith('(int)'):
            uFormatToUse = uFormatToUse[5:]
            uValue = uFormatToUse.format(int(ToFloat(uValue)))
        elif uFormatToUse.startswith('(float)'):
            uFormatToUse = uFormatToUse[7:]
            uValue = uFormatToUse.format(ToFloat(uValue))
        SetVar(uVarName=uVarName, oVarValue=uValue)
        return uValue
    except Exception as e:
        LogError(uMsg=u'Var_Format: Invalid Argument', oException=e)
        return u''
コード例 #30
0
def Var_Find(uVarName, uFindVar, uDestVar):
    """
    Finds the posiion of a substring in a variable value.
    The changed variable value will be returned and stored in the destination var (Triggers raised if set)

    :rtype: string
    :param string uVarName: The variable name for the action, from where the value is pulled
    :param string uFindVar: The string to search for
    :param string uDestVar: The name of the variable for the result (the Position) If not found, '-1' will be returned
    :return: The position of the substring
    """

    uValue = GetVar(uVarName=uVarName)
    uValue = uVarName
    if uValue == u'':
        uValue = uVarName
    uValue = ReplaceVars(uValue)

    uFindVar = ReplaceVars(uFindVar)
    iPos = uValue.find(uFindVar)
    uResult = ToUnicode(iPos)
    SetVar(uVarName=uDestVar, oVarValue=uResult)
    Logger.debug(u'Var_Find: [%s] in [%s] returned [%s]  (stored in [%s])' %
                 (uFindVar, uValue, uResult, uDestVar))
    return uResult