Пример #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 SetPictureNormal(self, uPictureNormal, bClearCache=False):
        """ sets the picture """

        try:
            uNewDefinitionContext = u''

            if "DEFINITIONPATH[" in uPictureNormal:
                uNewDefinitionContext, uPictureNormal = GetSetDefinitionName(
                    uPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uNewDefinitionContext)
            self.uPictureNormalVar = uPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(ReplaceVars(uPictureNormal))

            if self.oObject:
                self.oObject.source = ToAtlas(self.oFnPictureNormal)
                if bClearCache:
                    self.oObject.reload()

            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(u"Can't set picture:" + uPictureNormal, e)
            return False

        return True
Пример #3
0
    def SetPictureNormal(self,
                         uFnPictureNormal: str,
                         bClearCache: bool = False) -> bool:
        """ sets the picture """

        try:
            uNewDefinitionContext: str = u''

            if "DEFINITIONPATH[" in uFnPictureNormal:
                uNewDefinitionContext, uFnPictureNormal = GetSetDefinitionName(
                    uText=uFnPictureNormal)
            elif Globals.uDefinitionContext != self.uDefinitionContext:
                uNewDefinitionContext = self.uDefinitionContext
                SetDefinitionContext(uDefinitionName=uNewDefinitionContext)
            self.uFnPictureNormalVar = uFnPictureNormal
            self.oFnPictureNormal = self.oFnPictureNormal.Clear(
            ).ImportFullPath(uFnFullName=ReplaceVars(uFnPictureNormal))
            if self.oObject:
                self.oObject.source = ToAtlas(oFileName=self.oFnPictureNormal)
                if bClearCache:
                    if self.oObject._coreimage.filename is not None:
                        self.oObject.reload()
            if uNewDefinitionContext != '':
                RestoreDefinitionContext()
        except Exception as e:
            LogError(uMsg=u"Can't set picture:" + uFnPictureNormal,
                     oException=e)
            return False

        return True
Пример #4
0
    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
Пример #5
0
def Orca_include(elem, loader, uFileName="Unknown Filename"):
    """  heavyly customized loader for includes in xml files"""
    uAlias = elem.get('definitionalias')
    oDef = None
    if uAlias is not None:
        oDef = Globals.oDefinitions.dDefinitionList_Dict[uAlias]

    Orca_includesub(elem, loader, Globals.uDefinitionContext, oDef, uFileName)
    RestoreDefinitionContext()
Пример #6
0
    def LoadSettings(self, uDefinitionName, fSplashScreenPercentageStartValue):
        """ Loads the settimgs for a specific definition """

        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Loading Definition Settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(
                self.aDefinitionList_List)

            aActions = Globals.oEvents.CreateSimpleActionList([{
                'name':
                'Show Message that we load the settings',
                'string':
                'showsplashtext',
                'maintext':
                '$lvar(414)'
            }])
            for oDefinition in reversed(self.aDefinitionList_List):
                fPercentage = fPercentage + fPercentageStep
                Globals.oEvents.AddToSimpleActionList(
                    aActions, [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }, {
                        'name': 'Load the settings for the Definition',
                        'string': 'loaddefinitionsettings',
                        'definitionname': oDefinition.uAlias
                    }])

            # Lets parse them (to init all default vars
            Globals.oEvents.AddToSimpleActionList(
                aActions, [{
                    'name': 'Parse all Settings and set defaults',
                    'string': 'loaddefinitionsettings',
                    'definitionname': 'PARSESETTINGS'
                }])
            #Execute the Queue
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
            #just to put it somewhere
            for uHintKey in self.dInstallationsHints:
                self.uInstallationHint += self.dInstallationsHints[uHintKey]
            SetVar(uVarName="INSTALLATIONHINT",
                   oVarValue=self.uInstallationHint)

        else:
            oDef = self.dDefinitionList_Dict[uDefinitionName]
            SetDefinitionContext(oDef.uName)
            oDef.ParseSettings()
            RestoreDefinitionContext()
Пример #7
0
 def GetUsedDefinitions(self):
     """ Gets a list of all used definitions """
     Logger.debug(u'Collecting used definitions...')
     fSplashScreenPercentageRange = 10.0
     Globals.oTheScreen.LogToSplashScreen("Collecting used definitions",
                                          fSplashScreenPercentageRange)
     self.__GetUsedDefinitions_Sub(Globals.uDefinitionName, True, True,
                                   True, True, Globals.oTheScreen.uDefName,
                                   Globals.uDefinitionName,
                                   cDefinitionVars(), u'')
     Globals.uDefinitionContext = ""  # to ensure, root definitioncontext is loaded
     RestoreDefinitionContext()
Пример #8
0
 def LoadGestures(self):
     """ Loads all Gestures descriptions for a definition """
     Logger.info('Loading Gestures for definition:' + self.uDefPublicTitle)
     if not self.uName in aLoadedGestures:
         aLoadedGestures.append(self.uName)
         if Globals.oFnGestures.Exists():
             SetDefinitionContext(self.uName)
             oET_Root = LoadXMLFile(Globals.oFnGestures)
             Orca_include(oET_Root, orca_et_loader)
             LoadGesturesFromXML(oET_Root, u'gestures', u'gesture')
         RestoreDefinitionContext()
     SetVar(uVarName="ORCASTANDARDGESTURESINCLUDED", oVarValue="1")
Пример #9
0
def Orca_include(oElem, pLoader: Callable, uFileName: str = "") -> None:
    """  heavily customized loader for includes in xml files"""
    uAlias = oElem.get('definitionalias')
    oDef = None
    if uAlias is not None:
        oDef = Globals.oDefinitions[uAlias]

    oElem.set('linefilename', ShortenFileName(uFnFile=uFileName))

    Orca_includesub(oElem=oElem,
                    pLoader=pLoader,
                    uOrgDefinitionContext=Globals.uDefinitionContext,
                    oDef=oDef,
                    uFileName=uFileName)
    if Logger.getEffectiveLevel() == logging.DEBUG:
        AddFileNames(oElem=oElem, uFnFile=uFileName)
    RestoreDefinitionContext()
Пример #10
0
 def GetUsedDefinitions(self) -> None:
     """ Gets a list of all used definitions """
     Logger.debug(u'Collecting used definitions...')
     fSplashScreenPercentageRange: float = 10.0
     Globals.oTheScreen.LogToSplashScreen(
         uText="Collecting used definitions",
         uPercentage=str(fSplashScreenPercentageRange))
     self.__GetUsedDefinitions_Sub(
         uDefinitionName=Globals.uDefinitionName,
         bImportActions=True,
         bImportLanguages=True,
         bImportPages=True,
         bImportSettings=True,
         uParentDefinitionName=Globals.oTheScreen.uDefName,
         uParentDefinitionAlias=Globals.uDefinitionName,
         oDefinitionVarsFromParent=cDefinitionVars(),
         uAlias=u'')
     Globals.uDefinitionContext = ""  # to ensure, root definitioncontext is loaded
     RestoreDefinitionContext()
     return None
Пример #11
0
    def LoadActions(self) -> None:
        """ parses the definition specific actions """
        Logger.info(u'Loading Actions for definition:' + self.uDefPublicTitle)
        uET_Data: str
        SetDefinitionContext(uDefinitionName=self.uName)
        if Globals.oFnAction.Exists():
            uET_Data = CachedFile(oFileName=Globals.oFnAction)
            uET_Data = ReplaceDefVars(uET_Data, self.oDefinitionVars)
            oET_Root: Element = Orca_FromString(
                uET_Data=uET_Data,
                oDef=self,
                uFileName=Globals.oFnAction.string)
            Orca_include(oET_Root, orca_et_loader)
            SetDefinitionContext(uDefinitionName=self.uName)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'pagestartactions',
                uListTag=u'pagestartaction',
                dTargetDic=Globals.oActions.dActionsPageStart,
                uFileName=Globals.oFnAction)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'pagestartactions',
                uListTag=u'pagestopaction',
                dTargetDic=Globals.oActions.dActionsPageStop,
                uFileName=Globals.oFnAction)
            Globals.oActions.LoadActionsSub(
                oET_Root=oET_Root,
                uSegmentTag=u'actions',
                uListTag=u'action',
                dTargetDic=Globals.oActions.dActionsCommands,
                uFileName=Globals.oFnAction)

            SetVar(uVarName=u'ORCASTANDARDPAGESTARTACTIONSINCLUDED',
                   oVarValue=u"1")
            SetVar(uVarName=u'ORCASTANDARDACTIONSINCLUDED', oVarValue=u"1")
        RestoreDefinitionContext()
        return None
Пример #12
0
    def InitInterFaceSettings(self, uDefinitionName,
                              fSplashScreenPercentageStartValue):
        """ Init The Interface settings of a definition  """

        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Initialize Interface settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(
                self.aDefinitionList_List)

            aActions = Globals.oEvents.CreateSimpleActionList([{
                'name':
                'Show Message the we initialize the interfaces',
                'string':
                'showsplashtext',
                'maintext':
                '$lvar(418)'
            }])

            for oDefinition in reversed(self.aDefinitionList_List):
                fPercentage = fPercentage + fPercentageStep
                Globals.oEvents.AddToSimpleActionList(
                    aActions, [{
                        'name': 'Update Percentage and Interface Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }, {
                        'name': 'Initialize the Interface',
                        'string': 'initinterfacesettings',
                        'definitionname': oDefinition.uAlias
                    }])
            Globals.oEvents.AddToSimpleActionList(
                aActions, [{
                    'name': 'Show Message the we write all interface settings',
                    'string': 'showsplashtext',
                    'subtext': "$lvar(456)",
                    'percentage': str(fPercentage)
                }, {
                    'name': 'Write all interface settings',
                    'string': 'initinterfacesettings',
                    'definitionname': 'WRITEALLSETTINGS'
                }])

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)

        elif uDefinitionName == "WRITEALLSETTINGS":
            for uInterfaceName in self.dInitInterfaceSettings:
                if uInterfaceName in Globals.oInterFaces.oInterfaceList:
                    oInterface = Globals.oInterFaces.dInterfaces.get(
                        uInterfaceName)
                    if oInterface is None:
                        Logger.info(
                            'Need to load unrecognized Interface [%s] for configuration'
                            % (uInterfaceName))
                        Globals.oInterFaces.LoadInterface(uInterfaceName)
                        oInterface = Globals.oInterFaces.dInterfaces.get(
                            uInterfaceName)
                    if oInterface is not None:
                        for uConfigurationName in self.dInitInterfaceSettings[
                                uInterfaceName]:
                            oInterface.oInterFaceConfig.WriteDefinitionConfig(
                                uSectionName=uConfigurationName,
                                dSettings=self.dInitInterfaceSettings[
                                    uInterfaceName][uConfigurationName])
                else:
                    Logger.warning(
                        'Interface [%s] not on device, so it will not be configured!'
                        % (uInterfaceName))

        else:
            oDef = self.dDefinitionList_Dict[uDefinitionName]
            SetDefinitionContext(oDef.uName)
            oXMLRoot = oDef.oET_Root
            oDef.InitInterFaceSettings(oXMLRoot)
            RestoreDefinitionContext()
Пример #13
0
    def LoadSettings(self, *, uDefinitionName: str,
                     fSplashScreenPercentageStartValue: float) -> None:
        """ Loads the settings for a specific definition """

        oDefinition: cDefinition
        aCommands: List[Dict[str, str]]
        uHintKey: str
        fSplashScreenPercentageRange: float = 10.0

        if not uDefinitionName:
            # Scheduling Loading Definition Settings
            fPercentage: float = fSplashScreenPercentageStartValue
            fPercentageStep: float = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message that we load the settings',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(414)'
                }])
            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Definition Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Load the settings for the Definition',
                    'string': 'loaddefinitionsettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)

            # Lets parse them (to init all default vars
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Parse all Settings and set defaults',
                    'string': 'loaddefinitionsettings',
                    'definitionname': 'PARSESETTINGS'
                }])
            #Execute the Queue
            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)
            #just to put it somewhere
            for uHintKey in self.dInstallationsHints:
                self.uInstallationHint += self.dInstallationsHints[uHintKey]
            SetVar(uVarName="INSTALLATIONHINT",
                   oVarValue=self.uInstallationHint)

        else:
            oDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDefinition.uName)
            oDefinition.ParseSettings()
            RestoreDefinitionContext()
        return None
Пример #14
0
    def InitInterFaceSettings(
            self, *, uDefinitionName: str,
            fSplashScreenPercentageStartValue: float) -> None:
        """ Init The Interface settings of a definition  """

        aCommands: List[Dict[str, str]]
        oInterface: cBaseInterFace
        fSplashScreenPercentageRange = 10.0

        if not uDefinitionName:
            # Scheduling Initialize Interface settings
            fPercentage = fSplashScreenPercentageStartValue
            fPercentageStep = fSplashScreenPercentageRange / len(self)

            aActions: List[cAction] = Globals.oEvents.CreateSimpleActionList(
                aActions=[{
                    'name': 'Show Message the we initialize the interfaces',
                    'string': 'showsplashtext',
                    'maintext': '$lvar(418)'
                }])

            for uDefinitionKey in reversed(self):
                oDefinition = self[uDefinitionKey]
                fPercentage += fPercentageStep
                if Logger.getEffectiveLevel() != logging.DEBUG:
                    aCommands = []
                else:
                    aCommands = [{
                        'name': 'Update Percentage and Interface Name',
                        'string': 'showsplashtext',
                        'subtext': oDefinition.uDefPublicTitle,
                        'percentage': str(fPercentage)
                    }]
                aCommands.append({
                    'name': 'Initialize the Interface',
                    'string': 'initinterfacesettings',
                    'definitionname': oDefinition.uAlias
                })
                Globals.oEvents.AddToSimpleActionList(aActionList=aActions,
                                                      aActions=aCommands)
            Globals.oEvents.AddToSimpleActionList(
                aActionList=aActions,
                aActions=[{
                    'name': 'Show Message the we write all interface settings',
                    'string': 'showsplashtext',
                    'subtext': "$lvar(456)",
                    'percentage': str(fPercentage)
                }, {
                    'name': 'Write all interface settings',
                    'string': 'initinterfacesettings',
                    'definitionname': 'WRITEALLSETTINGS'
                }])

            Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions,
                                                   oParentWidget=None)

        elif uDefinitionName == "WRITEALLSETTINGS":
            for uInterfaceName in self.dInitInterfaceSettings:
                if uInterfaceName in Globals.oInterFaces.aObjectNameList:
                    oInterface = Globals.oInterFaces.GetInterface(
                        uInterfaceName)
                    if oInterface is None:
                        Logger.info(
                            'Need to load unrecognized Interface [%s] for configuration'
                            % uInterfaceName)
                        Globals.oInterFaces.LoadInterface(uInterfaceName)
                        oInterface = Globals.oInterFaces.GetInterface(
                            uInterfaceName)
                    if oInterface is not None:
                        for uConfigurationName in self.dInitInterfaceSettings[
                                uInterfaceName]:
                            oInterface.oObjectConfig.WriteDefinitionConfig(
                                uSectionName=uConfigurationName,
                                dSettings=self.dInitInterfaceSettings[
                                    uInterfaceName][uConfigurationName])
                else:
                    Logger.warning(
                        'Interface [%s] not on device, so it will not be configured!'
                        % uInterfaceName)

        else:
            oDef: cDefinition = self[uDefinitionName]
            SetDefinitionContext(uDefinitionName=oDef.uName)
            oDef.InitInterFaceSettings(oXMLRoot=oDef.oET_Root)
            RestoreDefinitionContext()
        return None