def LoadSoundsDescription(self) -> None: """ Loads the sound description (tunes) """ try: Logger.debug(u'TheScreen: Loading Sounds') oET_Root: Element = LoadXMLFile(oFile=Globals.oFnSoundsXml) if oET_Root is not None: for oXMLSound in oET_Root.findall('sound'): uSoundName: str = GetXMLTextAttribute(oXMLNode=oXMLSound, uTag=u'name', bMandatory=False, vDefault=u'') oFnSound: cFileName = cFileName('').ImportFullPath( uFnFullName=GetXMLTextAttribute(oXMLNode=oXMLSound, uTag=u'file', bMandatory=False, vDefault=u'')) if uSoundName in self.aSounds: self.aSounds[uSoundName]["oFnSound"] = oFnSound else: Logger.warning(u'Unknown Sound:' + oFnSound) except Exception as e: ShowErrorPopUp(uMessage=LogError( uMsg= u'TheScreen: LoadSoundDescription: can\'t load SoundDescription', oException=e))
def LoadActionsAppStart(self): """ Loads the appstart Actions """ Logger.debug(u'Load AppStart Actions XmlFile') oFnActionFile = cFileName(Globals.oFnActionEarlyAppStart) if not oFnActionFile.Exists(): if (len(Globals.aDefinitionList) == 0) and (not Globals.bProtected): oFnActionFile = Globals.oFnActionFreshInstall try: oET_Root = LoadXMLFile(oFnActionFile) self.LoadActionsSub(oET_Root, u'appstartactions', u'appstartaction', self.dActionsPageStart, oFnActionFile.string) # just in case we have some sub commands (mainly in the fall back actions command set) self.LoadActionsSub(oET_Root, u'actions', u'action', self.dActionsCommands, oFnActionFile.string) except Exception as e: uMsg = LogError( u'TheScreen: Fatal Error:Load Appstart Action XmlFile (%s)' % (oFnActionFile.string), e) ShowErrorPopUp(uTitle="Fatal Error", uMessage=uMsg, bAbort=True) aActions = self.dActionsPageStart.get(u'earlyappstart') if aActions: Logger.debug(u'TheScreen: Calling Early Application StartActions') Globals.oEvents.ExecuteActionsNewQueue(aActions=aActions, oParentWidget=None) oET_Root = None
def ExecuteAction(self,oAction): """ Executes a single action in a queue (excluding condition verifying)""" try: oAction.uActionString=ReplaceVars(oAction.uActionString) oFunction=self.dActionFunctions.get(oAction.iActionId) if oFunction: return oFunction(oAction) else: ''' this enables to use standardactions / actions without call, but assigning parameters like interface and configname ''' aActions=Globals.oActions.GetActionList(uActionName = oAction.uActionString, bNoCopy = True) if aActions: if len(aActions)>1: Logger.error("you can''t use multiline actions as short cut, use call instead") oFunction=self.dActionFunctions.get(aActions[0].iActionId) if oFunction: oAction.uActionString=ReplaceVars(aActions[0].uActionString) self.CopyActionPars(dTarget=oAction.dActionPars,dSource=aActions[0].dActionPars,uReplaceOption="donotreplacetarget") if not oAction.uRetVar: oAction.uRetVar=aActions[0].uRetVar return oFunction(oAction) Logger.error("ExecuteAction: Action not Found:"+oAction.uActionName+':'+oAction.uActionString) return 0 except Exception as e: uMsg=LogError('Error executing Action:'+self.CreateDebugLine(oAction=oAction, uTxt=''),e) ShowErrorPopUp(uMessage=uMsg) return False return False
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
def LoadActionsSub(self, oET_Root, uSegmentTag, uListTag, aTargetDic, uFileName=u''): """ replaceoptions * appendtoexisting * replaceexisting = replace current action * renameexisting = rename original actions if exist * renamemeifexist = rename this action """ try: if uSegmentTag: oET_SegmentsStart = oET_Root.find(uSegmentTag) else: oET_SegmentsStart = oET_Root if oET_SegmentsStart is not None: for oET_Includes in oET_SegmentsStart: if oET_Includes.tag == u'includes': self.LoadActionsSub(oET_Includes, None, uListTag, aTargetDic, uFileName) elif oET_Includes.tag == uListTag: uName = GetXMLTextAttribute(oET_Includes, 'name', True, u'') uReplaceOption = GetXMLTextAttribute( oET_Includes, 'replaceoption', False, u'appendtoexisting') uNewname = GetXMLTextAttribute(oET_Includes, 'newname', False, u'') aActions = [] bOldExist = True aActionsOrg = aTargetDic.get(uName) if aActionsOrg is None: aActionsOrg = [] bOldExist = False if uReplaceOption == 'appendtoexisting': aActions = aActionsOrg if uReplaceOption == 'renameexisting' and bOldExist: aTargetDic[uNewname] = aActionsOrg if uReplaceOption == 'renamemeifexist' and bOldExist: uName = uNewname self.__ParseXMLActions(oET_Includes, aActions) aTargetDic[uName] = aActions except Exception as e: uMsg = LogError(u'TheScreen: Fatal Error:Load Action XmlFile:', e) ShowErrorPopUp(uTitle="Fatal Error", uMessage=uMsg, bAbort=True)
def LoadXmlFile(self) -> None: """ reads all locales for a language """ self.oLocalesEntries.clear() try: oET_Root:Element = LoadXMLFile(oFile=Globals.oFnLangInfo) oXMLRegions:Element = oET_Root.find(u'regions') if oXMLRegions is not None: for oXMLRegion in oXMLRegions.findall(u'region'): self.__ParseXMLLocales(oXMLRegion) except ParseError as e: uMsg:str=LogError(uMsg=u'Language: Fatal Error:Load Locales XmlFile:',oException=e) ShowErrorPopUp(uTitle='Fatal Error',uMessage=uMsg, bAbort=True)